@@ -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
}
@@ -2299,7 +2296,6 @@ private function getAutoloadFile(): ?string
2299
2296
private function getClasses (Definition $ definition , string $ id ): array
2300
2297
{
2301
2298
$ classes = [];
2302
- $ resolve = $ this ->container ->getParameterBag ()->resolveValue (...);
2303
2299
2304
2300
while ($ definition instanceof Definition) {
2305
2301
foreach ($ definition ->getTag ($ this ->preloadTags [0 ]) as $ tag ) {
@@ -2311,24 +2307,24 @@ private function getClasses(Definition $definition, string $id): array
2311
2307
}
2312
2308
2313
2309
if ($ class = $ definition ->getClass ()) {
2314
- $ classes [] = trim ($ resolve ( $ class) , '\\' );
2310
+ $ classes [] = trim ($ class , '\\' );
2315
2311
}
2316
2312
$ factory = $ definition ->getFactory ();
2317
2313
2314
+ if (\is_string ($ factory ) && !str_starts_with ($ factory , '@= ' ) && str_contains ($ factory , ':: ' )) {
2315
+ $ factory = explode (':: ' , $ factory );
2316
+ }
2317
+
2318
2318
if (!\is_array ($ factory )) {
2319
- $ factory = [$ factory ];
2319
+ $ definition = $ factory ;
2320
+ continue ;
2320
2321
}
2321
2322
2322
- if (\is_string ($ factory [0 ])) {
2323
- $ factory [0 ] = $ resolve ($ factory [0 ]);
2323
+ $ definition = $ factory [0 ] ?? null ;
2324
2324
2325
- if (false !== $ i = strrpos ($ factory [0 ], ':: ' )) {
2326
- $ factory [0 ] = substr ($ factory [0 ], 0 , $ i );
2327
- }
2325
+ if (\is_string ($ definition )) {
2328
2326
$ classes [] = trim ($ factory [0 ], '\\' );
2329
2327
}
2330
-
2331
- $ definition = $ factory [0 ];
2332
2328
}
2333
2329
2334
2330
return $ classes ;
0 commit comments