@@ -61,14 +61,7 @@ public function getPasswordHasher($user): PasswordHasherInterface
6161 throw new \RuntimeException (sprintf ('No password hasher has been configured for account "%s". ' , \is_object ($ user ) ? get_debug_type ($ user ) : $ user ));
6262 }
6363
64- if (!$ this ->passwordHashers [$ hasherKey ] instanceof PasswordHasherInterface) {
65- $ this ->passwordHashers [$ hasherKey ] = $ this ->passwordHashers [$ hasherKey ] instanceof PasswordEncoderInterface
66- ? new PasswordHasherAdapter ($ this ->passwordHashers [$ hasherKey ])
67- : $ this ->createHasher ($ this ->passwordHashers [$ hasherKey ])
68- ;
69- }
70-
71- return $ this ->passwordHashers [$ hasherKey ];
64+ return $ this ->createHasherUsingAdapter ($ hasherKey );
7265 }
7366
7467 /**
@@ -111,6 +104,18 @@ private function createHasher(array $config, bool $isExtra = false): PasswordHas
111104 return new MigratingPasswordHasher ($ hasher , ...$ extrapasswordHashers );
112105 }
113106
107+ private function createHasherUsingAdapter (string $ hasherKey ): PasswordHasherInterface
108+ {
109+ if (!$ this ->passwordHashers [$ hasherKey ] instanceof PasswordHasherInterface) {
110+ $ this ->passwordHashers [$ hasherKey ] = $ this ->passwordHashers [$ hasherKey ] instanceof PasswordEncoderInterface
111+ ? new PasswordHasherAdapter ($ this ->passwordHashers [$ hasherKey ])
112+ : $ this ->createHasher ($ this ->passwordHashers [$ hasherKey ])
113+ ;
114+ }
115+
116+ return $ this ->passwordHashers [$ hasherKey ];
117+ }
118+
114119 private function getHasherConfigFromAlgorithm (array $ config ): array
115120 {
116121 if ('auto ' === $ config ['algorithm ' ]) {
@@ -142,8 +147,8 @@ private function getHasherConfigFromAlgorithm(array $config): array
142147 $ hasherChain = [$ this ->createHasher ($ config , true )];
143148
144149 foreach ($ frompasswordHashers as $ name ) {
145- if ($ hasher = $ this ->passwordHashers [$ name ] ?? false ) {
146- $ hasher = $ hasher instanceof PasswordHasherInterface ? $ hasher : $ this ->createHasher ( $ hasher , true );
150+ if (isset ( $ this ->passwordHashers [$ name ]) ) {
151+ $ hasher = $ this ->createHasherUsingAdapter ( $ name );
147152 } else {
148153 $ hasher = $ this ->createHasher (['algorithm ' => $ name ], true );
149154 }
0 commit comments