Skip to content

Commit be1de74

Browse files
committed
Renames, mainly Provider -> Extension
1 parent 4f825cb commit be1de74

20 files changed

+173
-165
lines changed

conf/config.neon

+1-8
Original file line numberDiff line numberDiff line change
@@ -2158,14 +2158,7 @@ services:
21582158
class: PHPStan\Reflection\BetterReflection\SourceStubber\ReflectionSourceStubberFactory
21592159

21602160
-
2161-
class: PHPStan\Reflection\Deprecation\DeprecationResolver
2162-
arguments:
2163-
propertyDeprecationProviders: tagged(phpstan.propertyDeprecationProvider)
2164-
methodDeprecationProviders: tagged(phpstan.methodDeprecationProvider)
2165-
classConstantDeprecationProviders: tagged(phpstan.classConstantDeprecationProvider)
2166-
classDeprecationProviders: tagged(phpstan.classDeprecationProvider)
2167-
functionDeprecationProviders: tagged(phpstan.functionDeprecationProvider)
2168-
constantDeprecationProviders: tagged(phpstan.constantDeprecationProvider)
2161+
class: PHPStan\Reflection\Deprecation\DeprecationProvider
21692162

21702163
php8Lexer:
21712164
class: PhpParser\Lexer\Emulative

src/Analyser/NodeScopeResolver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
use PHPStan\Reflection\Callables\SimpleImpurePoint;
138138
use PHPStan\Reflection\Callables\SimpleThrowPoint;
139139
use PHPStan\Reflection\ClassReflection;
140-
use PHPStan\Reflection\Deprecation\DeprecationResolver;
140+
use PHPStan\Reflection\Deprecation\DeprecationProvider;
141141
use PHPStan\Reflection\ExtendedMethodReflection;
142142
use PHPStan\Reflection\ExtendedParameterReflection;
143143
use PHPStan\Reflection\ExtendedParametersAcceptor;
@@ -256,7 +256,7 @@ public function __construct(
256256
private readonly StubPhpDocProvider $stubPhpDocProvider,
257257
private readonly PhpVersion $phpVersion,
258258
private readonly SignatureMapProvider $signatureMapProvider,
259-
private readonly DeprecationResolver $deprecationResolver,
259+
private readonly DeprecationProvider $deprecationResolver,
260260
private readonly AttributeReflectionFactory $attributeReflectionFactory,
261261
private readonly PhpDocInheritanceResolver $phpDocInheritanceResolver,
262262
private readonly FileHelper $fileHelper,

src/Reflection/BetterReflection/BetterReflectionProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
use PHPStan\Reflection\ClassReflection;
3737
use PHPStan\Reflection\Constant\RuntimeConstantReflection;
3838
use PHPStan\Reflection\ConstantReflection;
39-
use PHPStan\Reflection\Deprecation\DeprecationResolver;
39+
use PHPStan\Reflection\Deprecation\DeprecationProvider;
4040
use PHPStan\Reflection\FunctionReflection;
4141
use PHPStan\Reflection\FunctionReflectionFactory;
4242
use PHPStan\Reflection\InitializerExprContext;
@@ -86,7 +86,7 @@ public function __construct(
8686
private Reflector $reflector,
8787
private FileTypeMapper $fileTypeMapper,
8888
private PhpDocInheritanceResolver $phpDocInheritanceResolver,
89-
private DeprecationResolver $deprecationResolver,
89+
private DeprecationProvider $deprecationResolver,
9090
private PhpVersion $phpVersion,
9191
private NativeFunctionReflectionProvider $nativeFunctionReflectionProvider,
9292
private StubPhpDocProvider $stubPhpDocProvider,

src/Reflection/ClassReflection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use PHPStan\PhpDoc\Tag\TemplateTag;
2727
use PHPStan\PhpDoc\Tag\TypeAliasImportTag;
2828
use PHPStan\PhpDoc\Tag\TypeAliasTag;
29-
use PHPStan\Reflection\Deprecation\DeprecationResolver;
29+
use PHPStan\Reflection\Deprecation\DeprecationProvider;
3030
use PHPStan\Reflection\Php\PhpClassReflectionExtension;
3131
use PHPStan\Reflection\Php\PhpPropertyReflection;
3232
use PHPStan\Reflection\Php\UniversalObjectCratesClassReflectionExtension;
@@ -162,7 +162,7 @@ public function __construct(
162162
private PhpDocInheritanceResolver $phpDocInheritanceResolver,
163163
private PhpVersion $phpVersion,
164164
private SignatureMapProvider $signatureMapProvider,
165-
private DeprecationResolver $deprecationResolver,
165+
private DeprecationProvider $deprecationResolver,
166166
private AttributeReflectionFactory $attributeReflectionFactory,
167167
private array $propertiesClassReflectionExtensions,
168168
private array $methodsClassReflectionExtensions,

src/Reflection/Deprecation/ClassConstantDeprecationProvider.php renamed to src/Reflection/Deprecation/ClassConstantDeprecationExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* -
1515
* class: App\PHPStan\MyProvider
1616
* tags:
17-
* - phpstan.classConstantDeprecationProvider
17+
* - phpstan.classConstantDeprecationExtension
1818
* ```
1919
*
2020
* @api
2121
*/
22-
interface ClassConstantDeprecationProvider
22+
interface ClassConstantDeprecationExtension
2323
{
2424

2525
public function getClassConstantDeprecation(ReflectionClassConstant $reflection): ?Deprecation;

src/Reflection/Deprecation/ClassDeprecationProvider.php renamed to src/Reflection/Deprecation/ClassDeprecationExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
* -
1616
* class: App\PHPStan\MyProvider
1717
* tags:
18-
* - phpstan.classDeprecationProvider
18+
* - phpstan.classDeprecationExtension
1919
* ```
2020
*
2121
* @api
2222
*/
23-
interface ClassDeprecationProvider
23+
interface ClassDeprecationExtension
2424
{
2525

2626
public function getClassDeprecation(ReflectionClass|ReflectionEnum $reflection): ?Deprecation;

src/Reflection/Deprecation/ConstantDeprecationProvider.php renamed to src/Reflection/Deprecation/ConstantDeprecationExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* -
1515
* class: App\PHPStan\MyProvider
1616
* tags:
17-
* - phpstan.constantDeprecationProvider
17+
* - phpstan.constantDeprecationExtension
1818
* ```
1919
*
2020
* @api
2121
*/
22-
interface ConstantDeprecationProvider
22+
interface ConstantDeprecationExtension
2323
{
2424

2525
public function getConstantDeprecation(ReflectionConstant $reflection): ?Deprecation;

src/Reflection/Deprecation/Deprecation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public function getDescription(): ?string
2424
return $this->description;
2525
}
2626

27-
public function withDescription(?string $description): self
27+
public static function createWithDescription(string $description): self
2828
{
29-
$clone = clone $this;
29+
$clone = new self();
3030
$clone->description = $description;
3131

3232
return $clone;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Reflection\Deprecation;
4+
5+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass;
6+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClassConstant;
7+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum;
8+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionFunction;
9+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionMethod;
10+
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionProperty;
11+
use PHPStan\BetterReflection\Reflection\ReflectionConstant;
12+
use PHPStan\DependencyInjection\Container;
13+
14+
final class DeprecationProvider
15+
{
16+
17+
/** @var array<PropertyDeprecationExtension> $propertyDeprecationExtensions */
18+
private array $propertyDeprecationExtensions;
19+
20+
/** @var array<MethodDeprecationExtension> $methodDeprecationExtensions */
21+
private array $methodDeprecationExtensions;
22+
23+
/** @var array<ClassConstantDeprecationExtension> $classConstantDeprecationExtensions */
24+
private array $classConstantDeprecationExtensions;
25+
26+
/** @var array<ClassDeprecationExtension> $classDeprecationExtensions */
27+
private array $classDeprecationExtensions;
28+
29+
/** @var array<FunctionDeprecationExtension> $functionDeprecationExtensions */
30+
private array $functionDeprecationExtensions;
31+
32+
/** @var array<ConstantDeprecationExtension> $constantDeprecationExtensions */
33+
private array $constantDeprecationExtensions;
34+
35+
public function __construct(
36+
Container $container,
37+
)
38+
{
39+
$this->propertyDeprecationExtensions = $container->getServicesByTag('phpstan.propertyDeprecationExtension');
40+
$this->methodDeprecationExtensions = $container->getServicesByTag('phpstan.methodDeprecationExtension');
41+
$this->classConstantDeprecationExtensions = $container->getServicesByTag('phpstan.classConstantDeprecationExtension');
42+
$this->classDeprecationExtensions = $container->getServicesByTag('phpstan.classDeprecationExtension');
43+
$this->functionDeprecationExtensions = $container->getServicesByTag('phpstan.functionDeprecationExtension');
44+
$this->constantDeprecationExtensions = $container->getServicesByTag('phpstan.constantDeprecationExtension');
45+
}
46+
47+
public function getPropertyDeprecation(ReflectionProperty $reflectionProperty): ?Deprecation
48+
{
49+
foreach ($this->propertyDeprecationExtensions as $extension) {
50+
$deprecation = $extension->getPropertyDeprecation($reflectionProperty);
51+
if ($deprecation !== null) {
52+
return $deprecation;
53+
}
54+
}
55+
56+
return null;
57+
}
58+
59+
public function getMethodDeprecation(ReflectionMethod $methodReflection): ?Deprecation
60+
{
61+
foreach ($this->methodDeprecationExtensions as $extension) {
62+
$deprecation = $extension->getMethodDeprecation($methodReflection);
63+
if ($deprecation !== null) {
64+
return $deprecation;
65+
}
66+
}
67+
68+
return null;
69+
}
70+
71+
public function getClassConstantDeprecation(ReflectionClassConstant $reflectionConstant): ?Deprecation
72+
{
73+
foreach ($this->classConstantDeprecationExtensions as $extension) {
74+
$deprecation = $extension->getClassConstantDeprecation($reflectionConstant);
75+
if ($deprecation !== null) {
76+
return $deprecation;
77+
}
78+
}
79+
80+
return null;
81+
}
82+
83+
public function isClassDeprecated(ReflectionClass|ReflectionEnum $reflection): ?Deprecation
84+
{
85+
foreach ($this->classDeprecationExtensions as $extension) {
86+
$deprecation = $extension->getClassDeprecation($reflection);
87+
if ($deprecation !== null) {
88+
return $deprecation;
89+
}
90+
}
91+
92+
return null;
93+
}
94+
95+
public function getFunctionDeprecation(ReflectionFunction $reflectionFunction): ?Deprecation
96+
{
97+
foreach ($this->functionDeprecationExtensions as $extension) {
98+
$deprecation = $extension->getFunctionDeprecation($reflectionFunction);
99+
if ($deprecation !== null) {
100+
return $deprecation;
101+
}
102+
}
103+
104+
return null;
105+
}
106+
107+
public function getConstantDeprecation(ReflectionConstant $constantReflection): ?Deprecation
108+
{
109+
foreach ($this->constantDeprecationExtensions as $extension) {
110+
$deprecation = $extension->getConstantDeprecation($constantReflection);
111+
if ($deprecation !== null) {
112+
return $deprecation;
113+
}
114+
}
115+
116+
return null;
117+
}
118+
119+
}

src/Reflection/Deprecation/DeprecationResolver.php

-107
This file was deleted.

src/Reflection/Deprecation/FunctionDeprecationProvider.php renamed to src/Reflection/Deprecation/FunctionDeprecationExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* -
1515
* class: App\PHPStan\MyProvider
1616
* tags:
17-
* - phpstan.functionDeprecationProvider
17+
* - phpstan.functionDeprecationExtension
1818
* ```
1919
*
2020
* @api
2121
*/
22-
interface FunctionDeprecationProvider
22+
interface FunctionDeprecationExtension
2323
{
2424

2525
public function getFunctionDeprecation(ReflectionFunction $reflection): ?Deprecation;

src/Reflection/Deprecation/MethodDeprecationProvider.php renamed to src/Reflection/Deprecation/MethodDeprecationExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* -
1515
* class: App\PHPStan\MyProvider
1616
* tags:
17-
* - phpstan.methodDeprecationProvider
17+
* - phpstan.methodDeprecationExtension
1818
* ```
1919
*
2020
* @api
2121
*/
22-
interface MethodDeprecationProvider
22+
interface MethodDeprecationExtension
2323
{
2424

2525
public function getMethodDeprecation(ReflectionMethod $reflection): ?Deprecation;

src/Reflection/Deprecation/PropertyDeprecationProvider.php renamed to src/Reflection/Deprecation/PropertyDeprecationExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* -
1515
* class: App\PHPStan\MyProvider
1616
* tags:
17-
* - phpstan.propertyDeprecationProvider
17+
* - phpstan.propertyDeprecationExtension
1818
* ```
1919
*
2020
* @api
2121
*/
22-
interface PropertyDeprecationProvider
22+
interface PropertyDeprecationExtension
2323
{
2424

2525
public function getPropertyDeprecation(ReflectionProperty $reflection): ?Deprecation;

0 commit comments

Comments
 (0)