Skip to content

Commit bdf3440

Browse files
committed
Map all BrokerFactory tags in AutowiredAttributeServicesExtension
1 parent 339a29d commit bdf3440

10 files changed

+91
-29
lines changed

conf/config.neon

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,6 @@ services:
753753
tags:
754754
- phpstan.broker.dynamicMethodReturnTypeExtension
755755

756-
-
757-
class: PHPStan\Reflection\BetterReflection\Type\AdapterReflectionEnumDynamicReturnTypeExtension
758-
tags:
759-
- phpstan.broker.dynamicMethodReturnTypeExtension
760-
761756
-
762757
class: PHPStan\Reflection\ConstructorsHelper
763758
arguments:
@@ -793,11 +788,6 @@ services:
793788
-
794789
class: PHPStan\Reflection\Php\Soap\SoapClientMethodsClassReflectionExtension
795790

796-
-
797-
class: PHPStan\Reflection\Php\EnumAllowedSubTypesClassReflectionExtension
798-
tags:
799-
- phpstan.broker.allowedSubTypesClassReflectionExtension
800-
801791
-
802792
class: PHPStan\Reflection\Php\UniversalObjectCratesClassReflectionExtension
803793
tags:
@@ -1071,10 +1061,6 @@ services:
10711061
arguments:
10721062
reportMagicProperties: %reportMagicProperties%
10731063
checkDynamicProperties: %checkDynamicProperties%
1074-
-
1075-
class: PHPStan\Type\Php\BcMathNumberOperatorTypeSpecifyingExtension
1076-
tags:
1077-
- phpstan.broker.operatorTypeSpecifyingExtension
10781064

10791065
-
10801066
class: PHPStan\Rules\Properties\UninitializedPropertyRule
@@ -1310,11 +1296,6 @@ services:
13101296
tags:
13111297
- phpstan.dynamicFunctionThrowTypeExtension
13121298

1313-
-
1314-
class: PHPStan\Type\Php\BackedEnumFromMethodDynamicReturnTypeExtension
1315-
tags:
1316-
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
1317-
13181299
-
13191300
class: PHPStan\Type\Php\Base64DecodeDynamicFunctionReturnTypeExtension
13201301
tags:
@@ -1544,11 +1525,6 @@ services:
15441525
tags:
15451526
- phpstan.dynamicFunctionThrowTypeExtension
15461527

1547-
-
1548-
class: PHPStan\Type\Php\OpenSslEncryptParameterOutTypeExtension
1549-
tags:
1550-
- phpstan.functionParameterOutTypeExtension
1551-
15521528
-
15531529
class: PHPStan\Type\Php\ParseStrParameterOutTypeExtension
15541530
tags:
@@ -1603,11 +1579,6 @@ services:
16031579
tags:
16041580
- phpstan.typeSpecifier.functionTypeSpecifyingExtension
16051581

1606-
-
1607-
class: PHPStan\Type\Php\SimpleXMLElementClassPropertyReflectionExtension
1608-
tags:
1609-
- phpstan.broker.propertiesClassReflectionExtension
1610-
16111582
-
16121583
class: PHPStan\Type\Php\SimpleXMLElementConstructorThrowTypeExtension
16131584
tags:

src/DependencyInjection/AutowiredAttributeServicesExtension.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,49 @@
44

55
use Nette\DI\CompilerExtension;
66
use olvlvl\ComposerAttributeCollector\Attributes;
7+
use PHPStan\Analyser\ResultCache\ResultCacheMetaExtension;
8+
use PHPStan\Analyser\TypeSpecifierFactory;
79
use PHPStan\Broker\BrokerFactory;
10+
use PHPStan\DependencyInjection\Type\LazyDynamicThrowTypeExtensionProvider;
11+
use PHPStan\DependencyInjection\Type\LazyParameterClosureTypeExtensionProvider;
12+
use PHPStan\DependencyInjection\Type\LazyParameterOutTypeExtensionProvider;
13+
use PHPStan\PhpDoc\StubFilesExtension;
14+
use PHPStan\PhpDoc\TypeNodeResolverExtension;
15+
use PHPStan\Reflection\AllowedSubTypesClassReflectionExtension;
16+
use PHPStan\Reflection\Deprecation\ClassConstantDeprecationExtension;
17+
use PHPStan\Reflection\Deprecation\ClassDeprecationExtension;
18+
use PHPStan\Reflection\Deprecation\EnumCaseDeprecationExtension;
19+
use PHPStan\Reflection\Deprecation\FunctionDeprecationExtension;
20+
use PHPStan\Reflection\Deprecation\MethodDeprecationExtension;
21+
use PHPStan\Reflection\Deprecation\PropertyDeprecationExtension;
22+
use PHPStan\Reflection\MethodsClassReflectionExtension;
23+
use PHPStan\Reflection\PropertiesClassReflectionExtension;
24+
use PHPStan\Rules\Constants\AlwaysUsedClassConstantsExtensionProvider;
825
use PHPStan\Rules\LazyRegistry;
26+
use PHPStan\Rules\Properties\ReadWritePropertiesExtensionProvider;
27+
use PHPStan\Rules\RestrictedUsage\RestrictedClassConstantUsageExtension;
28+
use PHPStan\Rules\RestrictedUsage\RestrictedClassNameUsageExtension;
29+
use PHPStan\Rules\RestrictedUsage\RestrictedFunctionUsageExtension;
30+
use PHPStan\Rules\RestrictedUsage\RestrictedMethodUsageExtension;
31+
use PHPStan\Rules\RestrictedUsage\RestrictedPropertyUsageExtension;
932
use PHPStan\Rules\Rule;
1033
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
34+
use PHPStan\Type\DynamicFunctionThrowTypeExtension;
35+
use PHPStan\Type\DynamicMethodReturnTypeExtension;
36+
use PHPStan\Type\DynamicMethodThrowTypeExtension;
37+
use PHPStan\Type\DynamicStaticMethodReturnTypeExtension;
38+
use PHPStan\Type\DynamicStaticMethodThrowTypeExtension;
39+
use PHPStan\Type\ExpressionTypeResolverExtension;
40+
use PHPStan\Type\FunctionParameterClosureTypeExtension;
41+
use PHPStan\Type\FunctionParameterOutTypeExtension;
42+
use PHPStan\Type\FunctionTypeSpecifyingExtension;
43+
use PHPStan\Type\MethodParameterClosureTypeExtension;
44+
use PHPStan\Type\MethodParameterOutTypeExtension;
45+
use PHPStan\Type\MethodTypeSpecifyingExtension;
46+
use PHPStan\Type\OperatorTypeSpecifyingExtension;
47+
use PHPStan\Type\StaticMethodParameterClosureTypeExtension;
48+
use PHPStan\Type\StaticMethodParameterOutTypeExtension;
49+
use PHPStan\Type\StaticMethodTypeSpecifyingExtension;
1150
use ReflectionClass;
1251

1352
final class AutowiredAttributeServicesExtension extends CompilerExtension
@@ -20,8 +59,44 @@ public function loadConfiguration(): void
2059
$builder = $this->getContainerBuilder();
2160

2261
$interfaceToTag = [
62+
PropertiesClassReflectionExtension::class => BrokerFactory::PROPERTIES_CLASS_REFLECTION_EXTENSION_TAG,
63+
MethodsClassReflectionExtension::class => BrokerFactory::METHODS_CLASS_REFLECTION_EXTENSION_TAG,
64+
AllowedSubTypesClassReflectionExtension::class => BrokerFactory::ALLOWED_SUB_TYPES_CLASS_REFLECTION_EXTENSION_TAG,
65+
DynamicMethodReturnTypeExtension::class => BrokerFactory::DYNAMIC_METHOD_RETURN_TYPE_EXTENSION_TAG,
66+
DynamicStaticMethodReturnTypeExtension::class => BrokerFactory::DYNAMIC_STATIC_METHOD_RETURN_TYPE_EXTENSION_TAG,
2367
DynamicFunctionReturnTypeExtension::class => BrokerFactory::DYNAMIC_FUNCTION_RETURN_TYPE_EXTENSION_TAG,
68+
OperatorTypeSpecifyingExtension::class => BrokerFactory::OPERATOR_TYPE_SPECIFYING_EXTENSION_TAG,
69+
ExpressionTypeResolverExtension::class => BrokerFactory::EXPRESSION_TYPE_RESOLVER_EXTENSION_TAG,
70+
TypeNodeResolverExtension::class => TypeNodeResolverExtension::EXTENSION_TAG,
2471
Rule::class => LazyRegistry::RULE_TAG,
72+
StubFilesExtension::class => StubFilesExtension::EXTENSION_TAG,
73+
AlwaysUsedClassConstantsExtensionProvider::class => AlwaysUsedClassConstantsExtensionProvider::EXTENSION_TAG,
74+
ReadWritePropertiesExtensionProvider::class => ReadWritePropertiesExtensionProvider::EXTENSION_TAG,
75+
FunctionTypeSpecifyingExtension::class => TypeSpecifierFactory::FUNCTION_TYPE_SPECIFYING_EXTENSION_TAG,
76+
MethodTypeSpecifyingExtension::class => TypeSpecifierFactory::METHOD_TYPE_SPECIFYING_EXTENSION_TAG,
77+
StaticMethodTypeSpecifyingExtension::class => TypeSpecifierFactory::STATIC_METHOD_TYPE_SPECIFYING_EXTENSION_TAG,
78+
DynamicFunctionThrowTypeExtension::class => LazyDynamicThrowTypeExtensionProvider::FUNCTION_TAG,
79+
DynamicMethodThrowTypeExtension::class => LazyDynamicThrowTypeExtensionProvider::METHOD_TAG,
80+
DynamicStaticMethodThrowTypeExtension::class => LazyDynamicThrowTypeExtensionProvider::STATIC_METHOD_TAG,
81+
FunctionParameterClosureTypeExtension::class => LazyParameterClosureTypeExtensionProvider::FUNCTION_TAG,
82+
MethodParameterClosureTypeExtension::class => LazyParameterClosureTypeExtensionProvider::METHOD_TAG,
83+
StaticMethodParameterClosureTypeExtension::class => LazyParameterClosureTypeExtensionProvider::STATIC_METHOD_TAG,
84+
FunctionParameterOutTypeExtension::class => LazyParameterOutTypeExtensionProvider::FUNCTION_TAG,
85+
MethodParameterOutTypeExtension::class => LazyParameterOutTypeExtensionProvider::METHOD_TAG,
86+
StaticMethodParameterOutTypeExtension::class => LazyParameterOutTypeExtensionProvider::STATIC_METHOD_TAG,
87+
ResultCacheMetaExtension::class => ResultCacheMetaExtension::EXTENSION_TAG,
88+
ClassConstantDeprecationExtension::class => ClassConstantDeprecationExtension::CLASS_CONSTANT_EXTENSION_TAG,
89+
ClassDeprecationExtension::class => ClassDeprecationExtension::CLASS_EXTENSION_TAG,
90+
EnumCaseDeprecationExtension::class => EnumCaseDeprecationExtension::ENUM_CASE_EXTENSION_TAG,
91+
FunctionDeprecationExtension::class => FunctionDeprecationExtension::FUNCTION_EXTENSION_TAG,
92+
MethodDeprecationExtension::class => MethodDeprecationExtension::METHOD_EXTENSION_TAG,
93+
PropertyDeprecationExtension::class => PropertyDeprecationExtension::PROPERTY_EXTENSION_TAG,
94+
RestrictedMethodUsageExtension::class => RestrictedMethodUsageExtension::METHOD_EXTENSION_TAG,
95+
RestrictedClassNameUsageExtension::class => RestrictedClassNameUsageExtension::CLASS_NAME_EXTENSION_TAG,
96+
RestrictedFunctionUsageExtension::class => RestrictedFunctionUsageExtension::FUNCTION_EXTENSION_TAG,
97+
RestrictedPropertyUsageExtension::class => RestrictedPropertyUsageExtension::PROPERTY_EXTENSION_TAG,
98+
RestrictedClassConstantUsageExtension::class => RestrictedClassConstantUsageExtension::CLASS_CONSTANT_EXTENSION_TAG,
99+
25100
];
26101

27102
foreach ($autowiredServiceClasses as $class) {

src/Reflection/BetterReflection/Type/AdapterReflectionEnumDynamicReturnTypeExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClassConstant;
99
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum;
1010
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionNamedType;
11+
use PHPStan\DependencyInjection\AutowiredService;
1112
use PHPStan\Php\PhpVersion;
1213
use PHPStan\Reflection\MethodReflection;
1314
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
@@ -22,6 +23,7 @@
2223
use PHPStan\Type\UnionType;
2324
use function in_array;
2425

26+
#[AutowiredService]
2527
final class AdapterReflectionEnumDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
2628
{
2729

src/Reflection/Php/EnumAllowedSubTypesClassReflectionExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
namespace PHPStan\Reflection\Php;
44

5+
use PHPStan\DependencyInjection\AutowiredService;
56
use PHPStan\Reflection\AllowedSubTypesClassReflectionExtension;
67
use PHPStan\Reflection\ClassReflection;
78
use PHPStan\Type\Enum\EnumCaseObjectType;
89
use function array_keys;
910

11+
#[AutowiredService]
1012
final class EnumAllowedSubTypesClassReflectionExtension implements AllowedSubTypesClassReflectionExtension
1113
{
1214

src/Type/Php/AssertThrowTypeExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
use PhpParser\Node\Expr\FuncCall;
66
use PHPStan\Analyser\Scope;
7+
use PHPStan\DependencyInjection\AutowiredService;
78
use PHPStan\Reflection\FunctionReflection;
89
use PHPStan\Type\DynamicFunctionThrowTypeExtension;
910
use PHPStan\Type\ObjectType;
1011
use PHPStan\Type\Type;
1112
use Throwable;
1213
use function count;
1314

15+
#[AutowiredService]
1416
final class AssertThrowTypeExtension implements DynamicFunctionThrowTypeExtension
1517
{
1618

src/Type/Php/BackedEnumFromMethodDynamicReturnTypeExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use BackedEnum;
66
use PhpParser\Node\Expr\StaticCall;
77
use PHPStan\Analyser\Scope;
8+
use PHPStan\DependencyInjection\AutowiredService;
89
use PHPStan\Reflection\MethodReflection;
910
use PHPStan\Type\DynamicStaticMethodReturnTypeExtension;
1011
use PHPStan\Type\Enum\EnumCaseObjectType;
@@ -14,6 +15,7 @@
1415
use function count;
1516
use function in_array;
1617

18+
#[AutowiredService]
1719
final class BackedEnumFromMethodDynamicReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension
1820
{
1921

src/Type/Php/BcMathNumberOperatorTypeSpecifyingExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPStan\Type\Php;
44

5+
use PHPStan\DependencyInjection\AutowiredService;
56
use PHPStan\Php\PhpVersion;
67
use PHPStan\Type\ErrorType;
78
use PHPStan\Type\NeverType;
@@ -10,6 +11,7 @@
1011
use PHPStan\Type\Type;
1112
use function in_array;
1213

14+
#[AutowiredService]
1315
final class BcMathNumberOperatorTypeSpecifyingExtension implements OperatorTypeSpecifyingExtension
1416
{
1517

src/Type/Php/OpenSslEncryptParameterOutTypeExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PhpParser\Node\Expr\FuncCall;
66
use PHPStan\Analyser\Scope;
7+
use PHPStan\DependencyInjection\AutowiredService;
78
use PHPStan\Reflection\FunctionReflection;
89
use PHPStan\Reflection\ParameterReflection;
910
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
@@ -17,6 +18,7 @@
1718
use function strtolower;
1819
use function substr;
1920

21+
#[AutowiredService]
2022
final class OpenSslEncryptParameterOutTypeExtension implements FunctionParameterOutTypeExtension
2123
{
2224

src/Type/Php/PregReplaceCallbackClosureTypeExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PhpParser\Node\Expr\FuncCall;
66
use PHPStan\Analyser\Scope;
7+
use PHPStan\DependencyInjection\AutowiredService;
78
use PHPStan\Reflection\FunctionReflection;
89
use PHPStan\Reflection\Native\NativeParameterReflection;
910
use PHPStan\Reflection\ParameterReflection;
@@ -13,6 +14,7 @@
1314
use PHPStan\Type\StringType;
1415
use PHPStan\Type\Type;
1516

17+
#[AutowiredService]
1618
final class PregReplaceCallbackClosureTypeExtension implements FunctionParameterClosureTypeExtension
1719
{
1820

src/Type/Php/SimpleXMLElementClassPropertyReflectionExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPStan\Type\Php;
44

5+
use PHPStan\DependencyInjection\AutowiredService;
56
use PHPStan\Reflection\ClassReflection;
67
use PHPStan\Reflection\Php\SimpleXMLElementProperty;
78
use PHPStan\Reflection\PropertiesClassReflectionExtension;
@@ -10,6 +11,7 @@
1011
use PHPStan\Type\NullType;
1112
use PHPStan\Type\ObjectType;
1213

14+
#[AutowiredService]
1315
final class SimpleXMLElementClassPropertyReflectionExtension implements PropertiesClassReflectionExtension
1416
{
1517

0 commit comments

Comments
 (0)