@@ -353,7 +353,7 @@ class %s extends {$options['class']}
353353EOF ;
354354
355355 foreach ($ this ->preload as $ class ) {
356- if (!$ class || str_contains ($ class , '$ ' ) || \in_array ($ class , ['int ' , 'float ' , 'string ' , 'bool ' , 'resource ' , 'object ' , 'array ' , 'null ' , 'callable ' , 'iterable ' , 'mixed ' , 'void ' ], true )) {
356+ if (!$ class || str_contains ($ class , '$ ' ) || \in_array ($ class , ['int ' , 'float ' , 'string ' , 'bool ' , 'resource ' , 'object ' , 'array ' , 'null ' , 'callable ' , 'iterable ' , 'mixed ' , 'void ' , ' never ' ], true )) {
357357 continue ;
358358 }
359359 if (!(class_exists ($ class , false ) || interface_exists ($ class , false ) || trait_exists ($ class , false )) || (new \ReflectionClass ($ class ))->isUserDefined ()) {
@@ -846,8 +846,7 @@ private function addService(string $id, Definition $definition): array
846846 if ($ class = $ definition ->getClass ()) {
847847 $ class = $ class instanceof Parameter ? '% ' .$ class .'% ' : $ this ->container ->resolveEnvPlaceholders ($ class );
848848 $ return [] = sprintf (str_starts_with ($ class , '% ' ) ? '@return object A %1$s instance ' : '@return \%s ' , ltrim ($ class , '\\' ));
849- } elseif ($ definition ->getFactory ()) {
850- $ factory = $ definition ->getFactory ();
849+ } elseif ($ factory = $ definition ->getFactory ()) {
851850 if (\is_string ($ factory ) && !str_starts_with ($ factory , '@= ' )) {
852851 $ return [] = sprintf ('@return object An instance returned by %s() ' , $ factory );
853852 } elseif (\is_array ($ factory ) && (\is_string ($ factory [0 ]) || $ factory [0 ] instanceof Definition || $ factory [0 ] instanceof Reference)) {
@@ -1170,9 +1169,7 @@ private function addNewInstance(Definition $definition, string $return = '', ?st
11701169 $ arguments [] = (\is_string ($ i ) ? $ i .': ' : '' ).$ this ->dumpValue ($ value );
11711170 }
11721171
1173- if (null !== $ definition ->getFactory ()) {
1174- $ callable = $ definition ->getFactory ();
1175-
1172+ if ($ callable = $ definition ->getFactory ()) {
11761173 if ('current ' === $ callable && [0 ] === array_keys ($ definition ->getArguments ()) && \is_array ($ value ) && [0 ] === array_keys ($ value )) {
11771174 return $ return .$ this ->dumpValue ($ value [0 ]).$ tail ;
11781175 }
@@ -2293,7 +2290,6 @@ private function getAutoloadFile(): ?string
22932290 private function getClasses (Definition $ definition , string $ id ): array
22942291 {
22952292 $ classes = [];
2296- $ resolve = $ this ->container ->getParameterBag ()->resolveValue (...);
22972293
22982294 while ($ definition instanceof Definition) {
22992295 foreach ($ definition ->getTag ($ this ->preloadTags [0 ]) as $ tag ) {
@@ -2305,24 +2301,24 @@ private function getClasses(Definition $definition, string $id): array
23052301 }
23062302
23072303 if ($ class = $ definition ->getClass ()) {
2308- $ classes [] = trim ($ resolve ( $ class) , '\\' );
2304+ $ classes [] = trim ($ class , '\\' );
23092305 }
23102306 $ factory = $ definition ->getFactory ();
23112307
2308+ if (\is_string ($ factory ) && !str_starts_with ($ factory , '@= ' ) && str_contains ($ factory , ':: ' )) {
2309+ $ factory = explode (':: ' , $ factory );
2310+ }
2311+
23122312 if (!\is_array ($ factory )) {
2313- $ factory = [$ factory ];
2313+ $ definition = $ factory ;
2314+ continue ;
23142315 }
23152316
2316- if (\is_string ($ factory [0 ])) {
2317- $ factory [0 ] = $ resolve ($ factory [0 ]);
2317+ $ definition = $ factory [0 ] ?? null ;
23182318
2319- if (false !== $ i = strrpos ($ factory [0 ], ':: ' )) {
2320- $ factory [0 ] = substr ($ factory [0 ], 0 , $ i );
2321- }
2319+ if (\is_string ($ definition )) {
23222320 $ classes [] = trim ($ factory [0 ], '\\' );
23232321 }
2324-
2325- $ definition = $ factory [0 ];
23262322 }
23272323
23282324 return $ classes ;
0 commit comments