@@ -353,7 +353,7 @@ class %s extends {$options['class']}
353
353
EOF ;
354
354
355
355
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 )) {
357
357
continue ;
358
358
}
359
359
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
846
846
if ($ class = $ definition ->getClass ()) {
847
847
$ class = $ class instanceof Parameter ? '% ' .$ class .'% ' : $ this ->container ->resolveEnvPlaceholders ($ class );
848
848
$ 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 ()) {
851
850
if (\is_string ($ factory ) && !str_starts_with ($ factory , '@= ' )) {
852
851
$ return [] = sprintf ('@return object An instance returned by %s() ' , $ factory );
853
852
} 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
1170
1169
$ arguments [] = (\is_string ($ i ) ? $ i .': ' : '' ).$ this ->dumpValue ($ value );
1171
1170
}
1172
1171
1173
- if (null !== $ definition ->getFactory ()) {
1174
- $ callable = $ definition ->getFactory ();
1175
-
1172
+ if ($ callable = $ definition ->getFactory ()) {
1176
1173
if ('current ' === $ callable && [0 ] === array_keys ($ definition ->getArguments ()) && \is_array ($ value ) && [0 ] === array_keys ($ value )) {
1177
1174
return $ return .$ this ->dumpValue ($ value [0 ]).$ tail ;
1178
1175
}
@@ -2293,7 +2290,6 @@ private function getAutoloadFile(): ?string
2293
2290
private function getClasses (Definition $ definition , string $ id ): array
2294
2291
{
2295
2292
$ classes = [];
2296
- $ resolve = $ this ->container ->getParameterBag ()->resolveValue (...);
2297
2293
2298
2294
while ($ definition instanceof Definition) {
2299
2295
foreach ($ definition ->getTag ($ this ->preloadTags [0 ]) as $ tag ) {
@@ -2305,24 +2301,24 @@ private function getClasses(Definition $definition, string $id): array
2305
2301
}
2306
2302
2307
2303
if ($ class = $ definition ->getClass ()) {
2308
- $ classes [] = trim ($ resolve ( $ class) , '\\' );
2304
+ $ classes [] = trim ($ class , '\\' );
2309
2305
}
2310
2306
$ factory = $ definition ->getFactory ();
2311
2307
2308
+ if (\is_string ($ factory ) && !str_starts_with ($ factory , '@= ' ) && str_contains ($ factory , ':: ' )) {
2309
+ $ factory = explode (':: ' , $ factory );
2310
+ }
2311
+
2312
2312
if (!\is_array ($ factory )) {
2313
- $ factory = [$ factory ];
2313
+ $ definition = $ factory ;
2314
+ continue ;
2314
2315
}
2315
2316
2316
- if (\is_string ($ factory [0 ])) {
2317
- $ factory [0 ] = $ resolve ($ factory [0 ]);
2317
+ $ definition = $ factory [0 ] ?? null ;
2318
2318
2319
- if (false !== $ i = strrpos ($ factory [0 ], ':: ' )) {
2320
- $ factory [0 ] = substr ($ factory [0 ], 0 , $ i );
2321
- }
2319
+ if (\is_string ($ definition )) {
2322
2320
$ classes [] = trim ($ factory [0 ], '\\' );
2323
2321
}
2324
-
2325
- $ definition = $ factory [0 ];
2326
2322
}
2327
2323
2328
2324
return $ classes ;
0 commit comments