@@ -30,6 +30,9 @@ class AuthenticationAdapter implements AdapterInterface
3030 private string $identity;
3131 private string $credential;
3232
33+ /**
34+ * @param array<non-empty-string, mixed> $config
35+ */
3336 #[Inject(
3437 EntityManagerInterface::class,
3538 'config.doctrine.authentication',
@@ -93,7 +96,7 @@ public function authenticate(): Result
9396 /** Check if the get credential method exists in the provided identity class */
9497 $getCredential = $this->validateMethod($identityClass, $this->config['orm_default']['credential_property']);
9598
96- /** If passwords don't match, return failure response */
99+ /** If passwords don't match, return a failure response */
97100 if (false === password_verify($this->getCredential(), $identityClass->$getCredential())) {
98101 return new Result(
99102 Result::FAILURE_CREDENTIAL_INVALID,
@@ -105,7 +108,7 @@ public function authenticate(): Result
105108 /** Check for extra validation options */
106109 if (! empty($this->config['orm_default']['options'])) {
107110 foreach ($this->config['orm_default']['options'] as $property => $option) {
108- /** Check if value for the current option is provided */
111+ /** Check if the value for the current option is provided */
109112 if (! array_key_exists('value', $option)) {
110113 throw new Exception(sprintf(
111114 self::OPTION_VALUE_NOT_PROVIDED,
@@ -114,7 +117,7 @@ public function authenticate(): Result
114117 ));
115118 }
116119
117- /** Check if message for the current option is provided */
120+ /** Check if a message for the current option is provided */
118121 if (! array_key_exists('message', $option)) {
119122 throw new Exception(sprintf(
120123 self::OPTION_VALUE_NOT_PROVIDED,
@@ -135,14 +138,20 @@ public function authenticate(): Result
135138 }
136139 }
137140
141+ /** @var non-empty-string[] $roles */
142+ $roles = array_map(
143+ fn (RoleInterface $role): string => (string) $role->getName()->value,
144+ $identityClass->getRoles()
145+ );
146+
138147 $adminIdentity = new AdminIdentity(
139148 $identityClass->getUuid()->toString(),
140- $identityClass->getIdentity(),
149+ (string) $identityClass->getIdentity(),
141150 $identityClass->getStatus(),
142- array_map(fn (RoleInterface $role): string => $role->getName()->value, $identityClass->getRoles()) ,
151+ $roles ,
143152 [
144- 'firstName' => $identityClass->getFirstName(),
145- 'lastName' => $identityClass->getLastName(),
153+ 'firstName' => (string) $identityClass->getFirstName(),
154+ 'lastName' => (string) $identityClass->getLastName(),
146155 ]
147156 );
148157
0 commit comments