@@ -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 }
@@ -2299,7 +2296,6 @@ private function getAutoloadFile(): ?string
22992296 private function getClasses (Definition $ definition , string $ id ): array
23002297 {
23012298 $ classes = [];
2302- $ resolve = $ this ->container ->getParameterBag ()->resolveValue (...);
23032299
23042300 while ($ definition instanceof Definition) {
23052301 foreach ($ definition ->getTag ($ this ->preloadTags [0 ]) as $ tag ) {
@@ -2311,24 +2307,24 @@ private function getClasses(Definition $definition, string $id): array
23112307 }
23122308
23132309 if ($ class = $ definition ->getClass ()) {
2314- $ classes [] = trim ($ resolve ( $ class) , '\\' );
2310+ $ classes [] = trim ($ class , '\\' );
23152311 }
23162312 $ factory = $ definition ->getFactory ();
23172313
2314+ if (\is_string ($ factory ) && !str_starts_with ($ factory , '@= ' ) && str_contains ($ factory , ':: ' )) {
2315+ $ factory = explode (':: ' , $ factory );
2316+ }
2317+
23182318 if (!\is_array ($ factory )) {
2319- $ factory = [$ factory ];
2319+ $ definition = $ factory ;
2320+ continue ;
23202321 }
23212322
2322- if (\is_string ($ factory [0 ])) {
2323- $ factory [0 ] = $ resolve ($ factory [0 ]);
2323+ $ definition = $ factory [0 ] ?? null ;
23242324
2325- if (false !== $ i = strrpos ($ factory [0 ], ':: ' )) {
2326- $ factory [0 ] = substr ($ factory [0 ], 0 , $ i );
2327- }
2325+ if (\is_string ($ definition )) {
23282326 $ classes [] = trim ($ factory [0 ], '\\' );
23292327 }
2330-
2331- $ definition = $ factory [0 ];
23322328 }
23332329
23342330 return $ classes ;
0 commit comments