Skip to content

Map all BrokerFactory tags in AutowiredAttributeServicesExtension #4021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: 2.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
400 changes: 0 additions & 400 deletions conf/config.neon

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions src/DependencyInjection/AutowiredAttributeServicesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,53 @@

use Nette\DI\CompilerExtension;
use olvlvl\ComposerAttributeCollector\Attributes;
use PHPStan\Analyser\ResultCache\ResultCacheMetaExtension;
use PHPStan\Analyser\TypeSpecifierFactory;
use PHPStan\Broker\BrokerFactory;
use PHPStan\DependencyInjection\Type\LazyDynamicThrowTypeExtensionProvider;
use PHPStan\DependencyInjection\Type\LazyParameterClosureTypeExtensionProvider;
use PHPStan\DependencyInjection\Type\LazyParameterOutTypeExtensionProvider;
use PHPStan\PhpDoc\StubFilesExtension;
use PHPStan\PhpDoc\TypeNodeResolverExtension;
use PHPStan\Reflection\AllowedSubTypesClassReflectionExtension;
use PHPStan\Reflection\Deprecation\ClassConstantDeprecationExtension;
use PHPStan\Reflection\Deprecation\ClassDeprecationExtension;
use PHPStan\Reflection\Deprecation\EnumCaseDeprecationExtension;
use PHPStan\Reflection\Deprecation\FunctionDeprecationExtension;
use PHPStan\Reflection\Deprecation\MethodDeprecationExtension;
use PHPStan\Reflection\Deprecation\PropertyDeprecationExtension;
use PHPStan\Reflection\MethodsClassReflectionExtension;
use PHPStan\Reflection\PropertiesClassReflectionExtension;
use PHPStan\Rules\Constants\AlwaysUsedClassConstantsExtension;
use PHPStan\Rules\Constants\AlwaysUsedClassConstantsExtensionProvider;
use PHPStan\Rules\LazyRegistry;
use PHPStan\Rules\Methods\AlwaysUsedMethodExtension;
use PHPStan\Rules\Methods\AlwaysUsedMethodExtensionProvider;
use PHPStan\Rules\Properties\ReadWritePropertiesExtension;
use PHPStan\Rules\Properties\ReadWritePropertiesExtensionProvider;
use PHPStan\Rules\RestrictedUsage\RestrictedClassConstantUsageExtension;
use PHPStan\Rules\RestrictedUsage\RestrictedClassNameUsageExtension;
use PHPStan\Rules\RestrictedUsage\RestrictedFunctionUsageExtension;
use PHPStan\Rules\RestrictedUsage\RestrictedMethodUsageExtension;
use PHPStan\Rules\RestrictedUsage\RestrictedPropertyUsageExtension;
use PHPStan\Rules\Rule;
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
use PHPStan\Type\DynamicFunctionThrowTypeExtension;
use PHPStan\Type\DynamicMethodReturnTypeExtension;
use PHPStan\Type\DynamicMethodThrowTypeExtension;
use PHPStan\Type\DynamicStaticMethodReturnTypeExtension;
use PHPStan\Type\DynamicStaticMethodThrowTypeExtension;
use PHPStan\Type\ExpressionTypeResolverExtension;
use PHPStan\Type\FunctionParameterClosureTypeExtension;
use PHPStan\Type\FunctionParameterOutTypeExtension;
use PHPStan\Type\FunctionTypeSpecifyingExtension;
use PHPStan\Type\MethodParameterClosureTypeExtension;
use PHPStan\Type\MethodParameterOutTypeExtension;
use PHPStan\Type\MethodTypeSpecifyingExtension;
use PHPStan\Type\OperatorTypeSpecifyingExtension;
use PHPStan\Type\StaticMethodParameterClosureTypeExtension;
use PHPStan\Type\StaticMethodParameterOutTypeExtension;
use PHPStan\Type\StaticMethodTypeSpecifyingExtension;
use ReflectionClass;

final class AutowiredAttributeServicesExtension extends CompilerExtension
Expand All @@ -20,8 +63,45 @@ public function loadConfiguration(): void
$builder = $this->getContainerBuilder();

$interfaceToTag = [
PropertiesClassReflectionExtension::class => BrokerFactory::PROPERTIES_CLASS_REFLECTION_EXTENSION_TAG,
MethodsClassReflectionExtension::class => BrokerFactory::METHODS_CLASS_REFLECTION_EXTENSION_TAG,
AllowedSubTypesClassReflectionExtension::class => BrokerFactory::ALLOWED_SUB_TYPES_CLASS_REFLECTION_EXTENSION_TAG,
DynamicMethodReturnTypeExtension::class => BrokerFactory::DYNAMIC_METHOD_RETURN_TYPE_EXTENSION_TAG,
DynamicStaticMethodReturnTypeExtension::class => BrokerFactory::DYNAMIC_STATIC_METHOD_RETURN_TYPE_EXTENSION_TAG,
DynamicFunctionReturnTypeExtension::class => BrokerFactory::DYNAMIC_FUNCTION_RETURN_TYPE_EXTENSION_TAG,
OperatorTypeSpecifyingExtension::class => BrokerFactory::OPERATOR_TYPE_SPECIFYING_EXTENSION_TAG,
ExpressionTypeResolverExtension::class => BrokerFactory::EXPRESSION_TYPE_RESOLVER_EXTENSION_TAG,
TypeNodeResolverExtension::class => TypeNodeResolverExtension::EXTENSION_TAG,
Rule::class => LazyRegistry::RULE_TAG,
StubFilesExtension::class => StubFilesExtension::EXTENSION_TAG,
AlwaysUsedClassConstantsExtension::class => AlwaysUsedClassConstantsExtensionProvider::EXTENSION_TAG,
AlwaysUsedMethodExtension::class => AlwaysUsedMethodExtensionProvider::EXTENSION_TAG,
ReadWritePropertiesExtension::class => ReadWritePropertiesExtensionProvider::EXTENSION_TAG,
FunctionTypeSpecifyingExtension::class => TypeSpecifierFactory::FUNCTION_TYPE_SPECIFYING_EXTENSION_TAG,
MethodTypeSpecifyingExtension::class => TypeSpecifierFactory::METHOD_TYPE_SPECIFYING_EXTENSION_TAG,
StaticMethodTypeSpecifyingExtension::class => TypeSpecifierFactory::STATIC_METHOD_TYPE_SPECIFYING_EXTENSION_TAG,
DynamicFunctionThrowTypeExtension::class => LazyDynamicThrowTypeExtensionProvider::FUNCTION_TAG,
DynamicMethodThrowTypeExtension::class => LazyDynamicThrowTypeExtensionProvider::METHOD_TAG,
DynamicStaticMethodThrowTypeExtension::class => LazyDynamicThrowTypeExtensionProvider::STATIC_METHOD_TAG,
FunctionParameterClosureTypeExtension::class => LazyParameterClosureTypeExtensionProvider::FUNCTION_TAG,
MethodParameterClosureTypeExtension::class => LazyParameterClosureTypeExtensionProvider::METHOD_TAG,
StaticMethodParameterClosureTypeExtension::class => LazyParameterClosureTypeExtensionProvider::STATIC_METHOD_TAG,
FunctionParameterOutTypeExtension::class => LazyParameterOutTypeExtensionProvider::FUNCTION_TAG,
MethodParameterOutTypeExtension::class => LazyParameterOutTypeExtensionProvider::METHOD_TAG,
StaticMethodParameterOutTypeExtension::class => LazyParameterOutTypeExtensionProvider::STATIC_METHOD_TAG,
ResultCacheMetaExtension::class => ResultCacheMetaExtension::EXTENSION_TAG,
ClassConstantDeprecationExtension::class => ClassConstantDeprecationExtension::CLASS_CONSTANT_EXTENSION_TAG,
ClassDeprecationExtension::class => ClassDeprecationExtension::CLASS_EXTENSION_TAG,
EnumCaseDeprecationExtension::class => EnumCaseDeprecationExtension::ENUM_CASE_EXTENSION_TAG,
FunctionDeprecationExtension::class => FunctionDeprecationExtension::FUNCTION_EXTENSION_TAG,
MethodDeprecationExtension::class => MethodDeprecationExtension::METHOD_EXTENSION_TAG,
PropertyDeprecationExtension::class => PropertyDeprecationExtension::PROPERTY_EXTENSION_TAG,
RestrictedMethodUsageExtension::class => RestrictedMethodUsageExtension::METHOD_EXTENSION_TAG,
RestrictedClassNameUsageExtension::class => RestrictedClassNameUsageExtension::CLASS_NAME_EXTENSION_TAG,
RestrictedFunctionUsageExtension::class => RestrictedFunctionUsageExtension::FUNCTION_EXTENSION_TAG,
RestrictedPropertyUsageExtension::class => RestrictedPropertyUsageExtension::PROPERTY_EXTENSION_TAG,
RestrictedClassConstantUsageExtension::class => RestrictedClassConstantUsageExtension::CLASS_CONSTANT_EXTENSION_TAG,

];

foreach ($autowiredServiceClasses as $class) {
Expand Down
2 changes: 2 additions & 0 deletions src/PhpDoc/SocketSelectStubFilesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace PHPStan\PhpDoc;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Php\PhpVersion;

#[AutowiredService]
final class SocketSelectStubFilesExtension implements StubFilesExtension
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace PHPStan\Reflection\BetterReflection\SourceStubber;

use PHPStan\BetterReflection\SourceLocator\SourceStubber\ReflectionSourceStubber;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Node\Printer\Printer;
use PHPStan\Php\PhpVersion;

#[AutowiredService]
final class ReflectionSourceStubberFactory
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClassConstant;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionNamedType;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Php\PhpVersion;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
Expand All @@ -22,6 +23,7 @@
use PHPStan\Type\UnionType;
use function in_array;

#[AutowiredService]
final class AdapterReflectionEnumDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{

Expand Down
2 changes: 2 additions & 0 deletions src/Reflection/Deprecation/DeprecationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionMethod;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionProperty;
use PHPStan\BetterReflection\Reflection\ReflectionConstant;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\DependencyInjection\Container;

#[AutowiredService]
final class DeprecationProvider
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace PHPStan\Reflection\Php;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Reflection\AllowedSubTypesClassReflectionExtension;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\Enum\EnumCaseObjectType;
use function array_keys;

#[AutowiredService]
final class EnumAllowedSubTypesClassReflectionExtension implements AllowedSubTypesClassReflectionExtension
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace PHPStan\Rules\Constants;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\DependencyInjection\Container;

#[AutowiredService]
final class LazyAlwaysUsedClassConstantsExtensionProvider implements AlwaysUsedClassConstantsExtensionProvider
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Node\FunctionReturnStatementsNode;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
Expand All @@ -12,6 +13,7 @@
/**
* @implements Rule<FunctionReturnStatementsNode>
*/
#[AutowiredService]
final class MissingCheckedExceptionInFunctionThrowsRule implements Rule
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Node\MethodReturnStatementsNode;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
Expand All @@ -12,6 +13,7 @@
/**
* @implements Rule<MethodReturnStatementsNode>
*/
#[AutowiredService]
final class MissingCheckedExceptionInMethodThrowsRule implements Rule
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Node\PropertyHookReturnStatementsNode;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
Expand All @@ -14,6 +15,7 @@
/**
* @implements Rule<PropertyHookReturnStatementsNode>
*/
#[AutowiredService]
final class MissingCheckedExceptionInPropertyHookThrowsRule implements Rule
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/FunctionReturnTypeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
use PhpParser\Node;
use PhpParser\Node\Expr;
use PHPStan\Analyser\Scope;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Type\ErrorType;
use PHPStan\Type\NeverType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeUtils;
use PHPStan\Type\VerbosityLevel;
use function sprintf;

#[AutowiredService]
final class FunctionReturnTypeCheck
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Functions/PrintfHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PHPStan\Rules\Functions;

use Nette\Utils\Strings;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Php\PhpVersion;
use function array_filter;
use function count;
Expand All @@ -11,6 +12,7 @@
use function strlen;
use const PREG_SET_ORDER;

#[AutowiredService]
final class PrintfHelper
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Generics/CrossCheckInterfacesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace PHPStan\Rules\Generics;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Rules\IdentifierRuleError;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\Type\VerbosityLevel;
use function array_key_exists;
use function sprintf;

#[AutowiredService]
final class CrossCheckInterfacesHelper
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Generics/GenericObjectTypeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PHPStan\Rules\Generics;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Rules\IdentifierRuleError;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\ShouldNotHappenException;
Expand All @@ -23,6 +24,7 @@
use function sprintf;
use function strtolower;

#[AutowiredService]
final class GenericObjectTypeCheck
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Generics/MethodTagTemplateTypeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PhpParser\Node\Stmt\ClassLike;
use PHPStan\Analyser\Scope;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Internal\SprintfHelper;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Rules\IdentifierRuleError;
Expand All @@ -15,6 +16,7 @@
use function array_merge;
use function sprintf;

#[AutowiredService]
final class MethodTagTemplateTypeCheck
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Generics/VarianceCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PHPStan\Rules\Generics;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Reflection\ExtendedParametersAcceptor;
use PHPStan\Rules\IdentifierRuleError;
use PHPStan\Rules\RuleErrorBuilder;
Expand All @@ -10,6 +11,7 @@
use PHPStan\Type\Type;
use function sprintf;

#[AutowiredService]
final class VarianceCheck
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/InternalTag/RestrictedInternalUsageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace PHPStan\Rules\InternalTag;

use PHPStan\Analyser\Scope;
use PHPStan\DependencyInjection\AutowiredService;
use function array_slice;
use function explode;
use function str_starts_with;

#[AutowiredService]
final class RestrictedInternalUsageHelper
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Methods/LazyAlwaysUsedMethodExtensionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace PHPStan\Rules\Methods;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\DependencyInjection\Container;

#[AutowiredService]
final class LazyAlwaysUsedMethodExtensionProvider implements AlwaysUsedMethodExtensionProvider
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Methods/MethodParameterComparisonHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PHPStan\Rules\Methods;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Php\PhpVersion;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
Expand All @@ -21,6 +22,7 @@
use function count;
use function sprintf;

#[AutowiredService]
final class MethodParameterComparisonHelper
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/Methods/MethodVisibilityComparisonHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace PHPStan\Rules\Methods;

use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\Php\PhpMethodFromParserNodeReflection;
use PHPStan\Rules\IdentifierRuleError;
use PHPStan\Rules\RuleErrorBuilder;
use function sprintf;

#[AutowiredService]
final class MethodVisibilityComparisonHelper
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/NullsafeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace PHPStan\Rules;

use PhpParser\Node\Expr;
use PHPStan\DependencyInjection\AutowiredService;

#[AutowiredService]
final class NullsafeCheck
{

Expand Down
2 changes: 2 additions & 0 deletions src/Rules/ParameterCastableToStringCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
use PhpParser\Node\Arg;
use PHPStan\Analyser\ArgumentsNormalizer;
use PHPStan\Analyser\Scope;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Reflection\ParameterReflection;
use PHPStan\Type\ErrorType;
use PHPStan\Type\Type;
use PHPStan\Type\VerbosityLevel;
use function sprintf;

#[AutowiredService]
final class ParameterCastableToStringCheck
{

Expand Down
Loading
Loading