File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed
Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -1150,11 +1150,6 @@ services:
11501150 -
11511151 class : PHPStan\Type\BitwiseFlagHelper
11521152
1153- -
1154- class : PHPStan\Type\Php\AbsFunctionDynamicReturnTypeExtension
1155- tags :
1156- - phpstan.broker.dynamicFunctionReturnTypeExtension
1157-
11581153 -
11591154 class : PHPStan\Type\Php\ArgumentBasedFunctionReturnTypeExtension
11601155 tags :
Original file line number Diff line number Diff line change 44
55use Nette \DI \CompilerExtension ;
66use olvlvl \ComposerAttributeCollector \Attributes ;
7+ use PHPStan \Broker \BrokerFactory ;
8+ use PHPStan \Type \DynamicFunctionReturnTypeExtension ;
9+ use ReflectionClass ;
710
811final class AutowiredAttributeServicesExtension extends CompilerExtension
912{
@@ -14,10 +17,24 @@ public function loadConfiguration(): void
1417 $ autowiredServiceClasses = Attributes::findTargetClasses (AutowiredService::class);
1518 $ builder = $ this ->getContainerBuilder ();
1619
20+ $ interfaceToTag = [
21+ DynamicFunctionReturnTypeExtension::class => BrokerFactory::DYNAMIC_FUNCTION_RETURN_TYPE_EXTENSION_TAG ,
22+ ];
23+
1724 foreach ($ autowiredServiceClasses as $ class ) {
18- $ builder ->addDefinition (null )
25+ $ reflection = new ReflectionClass ($ class ->name );
26+
27+ $ definition = $ builder ->addDefinition (null )
1928 ->setType ($ class ->name )
2029 ->setAutowired ();
30+
31+ foreach ($ interfaceToTag as $ interface => $ tag ) {
32+ if (!$ reflection ->implementsInterface ($ interface )) {
33+ continue ;
34+ }
35+
36+ $ definition ->addTag ($ tag );
37+ }
2138 }
2239 }
2340
Original file line number Diff line number Diff line change 44
55use PhpParser \Node \Expr \FuncCall ;
66use PHPStan \Analyser \Scope ;
7+ use PHPStan \DependencyInjection \AutowiredService ;
78use PHPStan \Reflection \FunctionReflection ;
89use PHPStan \Type \DynamicFunctionReturnTypeExtension ;
910use PHPStan \Type \ErrorType ;
1011use PHPStan \Type \Type ;
1112
13+ #[AutowiredService]
1214final class AbsFunctionDynamicReturnTypeExtension implements DynamicFunctionReturnTypeExtension
1315{
1416
You can’t perform that action at this time.
0 commit comments