Skip to content

Commit ea58997

Browse files
committed
Tags to be in const
1 parent 529f030 commit ea58997

9 files changed

+33
-7
lines changed

src/DependencyInjection/ConditionalTagsExtension.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
use PHPStan\Parser\RichParser;
1717
use PHPStan\PhpDoc\StubFilesExtension;
1818
use PHPStan\PhpDoc\TypeNodeResolverExtension;
19+
use PHPStan\Reflection\Deprecation\ClassConstantDeprecationExtension;
20+
use PHPStan\Reflection\Deprecation\ClassDeprecationExtension;
21+
use PHPStan\Reflection\Deprecation\EnumCaseDeprecationExtension;
22+
use PHPStan\Reflection\Deprecation\FunctionDeprecationExtension;
23+
use PHPStan\Reflection\Deprecation\MethodDeprecationExtension;
24+
use PHPStan\Reflection\Deprecation\PropertyDeprecationExtension;
1925
use PHPStan\Rules\Constants\AlwaysUsedClassConstantsExtensionProvider;
2026
use PHPStan\Rules\LazyRegistry;
2127
use PHPStan\Rules\Properties\ReadWritePropertiesExtensionProvider;
@@ -61,6 +67,12 @@ public function getConfigSchema(): Nette\Schema\Schema
6167
LazyParameterOutTypeExtensionProvider::STATIC_METHOD_TAG => $bool,
6268
DiagnoseExtension::EXTENSION_TAG => $bool,
6369
ResultCacheMetaExtension::EXTENSION_TAG => $bool,
70+
ClassConstantDeprecationExtension::CLASS_CONSTANT_EXTENSION_TAG => $bool,
71+
ClassDeprecationExtension::CLASS_EXTENSION_TAG => $bool,
72+
EnumCaseDeprecationExtension::ENUM_CASE_EXTENSION_TAG => $bool,
73+
FunctionDeprecationExtension::FUNCTION_EXTENSION_TAG => $bool,
74+
MethodDeprecationExtension::METHOD_EXTENSION_TAG => $bool,
75+
PropertyDeprecationExtension::PROPERTY_EXTENSION_TAG => $bool,
6476
])->min(1));
6577
}
6678

src/Reflection/Deprecation/ClassConstantDeprecationExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
interface ClassConstantDeprecationExtension
2323
{
2424

25+
public const CLASS_CONSTANT_EXTENSION_TAG = 'phpstan.classConstantDeprecationExtension';
26+
2527
public function getClassConstantDeprecation(ReflectionClassConstant $reflection): ?Deprecation;
2628

2729
}

src/Reflection/Deprecation/ClassDeprecationExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
interface ClassDeprecationExtension
2424
{
2525

26+
public const CLASS_EXTENSION_TAG = 'phpstan.classDeprecationExtension';
27+
2628
public function getClassDeprecation(ReflectionClass|ReflectionEnum $reflection): ?Deprecation;
2729

2830
}

src/Reflection/Deprecation/ConstantDeprecationExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
interface ConstantDeprecationExtension
2323
{
2424

25+
public const CONSTANT_EXTENSION_TAG = 'phpstan.constantDeprecationExtension';
26+
2527
public function getConstantDeprecation(ReflectionConstant $reflection): ?Deprecation;
2628

2729
}

src/Reflection/Deprecation/DeprecationProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545

4646
public function getPropertyDeprecation(ReflectionProperty $reflectionProperty): ?Deprecation
4747
{
48-
$this->propertyDeprecationExtensions ??= $this->container->getServicesByTag('phpstan.propertyDeprecationExtension');
48+
$this->propertyDeprecationExtensions ??= $this->container->getServicesByTag(PropertyDeprecationExtension::PROPERTY_EXTENSION_TAG);
4949

5050
foreach ($this->propertyDeprecationExtensions as $extension) {
5151
$deprecation = $extension->getPropertyDeprecation($reflectionProperty);
@@ -59,7 +59,7 @@ public function getPropertyDeprecation(ReflectionProperty $reflectionProperty):
5959

6060
public function getMethodDeprecation(ReflectionMethod $methodReflection): ?Deprecation
6161
{
62-
$this->methodDeprecationExtensions ??= $this->container->getServicesByTag('phpstan.methodDeprecationExtension');
62+
$this->methodDeprecationExtensions ??= $this->container->getServicesByTag(MethodDeprecationExtension::METHOD_EXTENSION_TAG);
6363

6464
foreach ($this->methodDeprecationExtensions as $extension) {
6565
$deprecation = $extension->getMethodDeprecation($methodReflection);
@@ -73,7 +73,7 @@ public function getMethodDeprecation(ReflectionMethod $methodReflection): ?Depre
7373

7474
public function getClassConstantDeprecation(ReflectionClassConstant $reflectionConstant): ?Deprecation
7575
{
76-
$this->classConstantDeprecationExtensions ??= $this->container->getServicesByTag('phpstan.classConstantDeprecationExtension');
76+
$this->classConstantDeprecationExtensions ??= $this->container->getServicesByTag(ClassConstantDeprecationExtension::CLASS_CONSTANT_EXTENSION_TAG);
7777

7878
foreach ($this->classConstantDeprecationExtensions as $extension) {
7979
$deprecation = $extension->getClassConstantDeprecation($reflectionConstant);
@@ -87,7 +87,7 @@ public function getClassConstantDeprecation(ReflectionClassConstant $reflectionC
8787

8888
public function getClassDeprecation(ReflectionClass|ReflectionEnum $reflection): ?Deprecation
8989
{
90-
$this->classDeprecationExtensions ??= $this->container->getServicesByTag('phpstan.classDeprecationExtension');
90+
$this->classDeprecationExtensions ??= $this->container->getServicesByTag(ClassDeprecationExtension::CLASS_EXTENSION_TAG);
9191

9292
foreach ($this->classDeprecationExtensions as $extension) {
9393
$deprecation = $extension->getClassDeprecation($reflection);
@@ -101,7 +101,7 @@ public function getClassDeprecation(ReflectionClass|ReflectionEnum $reflection):
101101

102102
public function getFunctionDeprecation(ReflectionFunction $reflectionFunction): ?Deprecation
103103
{
104-
$this->functionDeprecationExtensions ??= $this->container->getServicesByTag('phpstan.functionDeprecationExtension');
104+
$this->functionDeprecationExtensions ??= $this->container->getServicesByTag(FunctionDeprecationExtension::FUNCTION_EXTENSION_TAG);
105105

106106
foreach ($this->functionDeprecationExtensions as $extension) {
107107
$deprecation = $extension->getFunctionDeprecation($reflectionFunction);
@@ -115,7 +115,7 @@ public function getFunctionDeprecation(ReflectionFunction $reflectionFunction):
115115

116116
public function getConstantDeprecation(ReflectionConstant $constantReflection): ?Deprecation
117117
{
118-
$this->constantDeprecationExtensions ??= $this->container->getServicesByTag('phpstan.constantDeprecationExtension');
118+
$this->constantDeprecationExtensions ??= $this->container->getServicesByTag(ConstantDeprecationExtension::CONSTANT_EXTENSION_TAG);
119119

120120
foreach ($this->constantDeprecationExtensions as $extension) {
121121
$deprecation = $extension->getConstantDeprecation($constantReflection);
@@ -129,7 +129,7 @@ public function getConstantDeprecation(ReflectionConstant $constantReflection):
129129

130130
public function getEnumCaseDeprecation(ReflectionEnumUnitCase|ReflectionEnumBackedCase $enumCaseReflection): ?Deprecation
131131
{
132-
$this->enumCaseDeprecationExtensions ??= $this->container->getServicesByTag('phpstan.enumCaseDeprecationExtension');
132+
$this->enumCaseDeprecationExtensions ??= $this->container->getServicesByTag(EnumCaseDeprecationExtension::ENUM_CASE_EXTENSION_TAG);
133133

134134
foreach ($this->enumCaseDeprecationExtensions as $extension) {
135135
$deprecation = $extension->getEnumCaseDeprecation($enumCaseReflection);

src/Reflection/Deprecation/EnumCaseDeprecationExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
interface EnumCaseDeprecationExtension
2424
{
2525

26+
public const ENUM_CASE_EXTENSION_TAG = 'phpstan.enumCaseDeprecationExtension';
27+
2628
public function getEnumCaseDeprecation(ReflectionEnumUnitCase|ReflectionEnumBackedCase $reflection): ?Deprecation;
2729

2830
}

src/Reflection/Deprecation/FunctionDeprecationExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
interface FunctionDeprecationExtension
2323
{
2424

25+
public const FUNCTION_EXTENSION_TAG = 'phpstan.functionDeprecationExtension';
26+
2527
public function getFunctionDeprecation(ReflectionFunction $reflection): ?Deprecation;
2628

2729
}

src/Reflection/Deprecation/MethodDeprecationExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
interface MethodDeprecationExtension
2323
{
2424

25+
public const METHOD_EXTENSION_TAG = 'phpstan.methodDeprecationExtension';
26+
2527
public function getMethodDeprecation(ReflectionMethod $reflection): ?Deprecation;
2628

2729
}

src/Reflection/Deprecation/PropertyDeprecationExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
interface PropertyDeprecationExtension
2323
{
2424

25+
public const PROPERTY_EXTENSION_TAG = 'phpstan.propertyDeprecationExtension';
26+
2527
public function getPropertyDeprecation(ReflectionProperty $reflection): ?Deprecation;
2628

2729
}

0 commit comments

Comments
 (0)