Skip to content

Commit 6fcb314

Browse files
committed
Introduce isDeprecated to CallableParametersAcceptor
1 parent 46b9819 commit 6fcb314

11 files changed

+55
-0
lines changed

src/Reflection/Callables/CallableParametersAcceptor.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public function getThrowPoints(): array;
1919

2020
public function isPure(): TrinaryLogic;
2121

22+
public function isDeprecated(): TrinaryLogic;
23+
2224
public function acceptsNamedArguments(): TrinaryLogic;
2325

2426
/**

src/Reflection/Callables/FunctionCallableVariant.php

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ public function isPure(): TrinaryLogic
135135
return $certainCount > 0 ? TrinaryLogic::createNo() : TrinaryLogic::createMaybe();
136136
}
137137

138+
public function isDeprecated(): TrinaryLogic
139+
{
140+
return $this->function->isDeprecated();
141+
}
142+
138143
public function getImpurePoints(): array
139144
{
140145
if ($this->impurePoints !== null) {

src/Reflection/ExtendedCallableFunctionVariant.php

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct(
3232
?TemplateTypeVarianceMap $callSiteVarianceMap,
3333
private array $throwPoints,
3434
private TrinaryLogic $isPure,
35+
private TrinaryLogic $isDeprecated,
3536
private array $impurePoints,
3637
private array $invalidateExpressions,
3738
private array $usedVariables,
@@ -60,6 +61,11 @@ public function isPure(): TrinaryLogic
6061
return $this->isPure;
6162
}
6263

64+
public function isDeprecated(): TrinaryLogic
65+
{
66+
return $this->isDeprecated;
67+
}
68+
6369
public function getImpurePoints(): array
6470
{
6571
return $this->impurePoints;

src/Reflection/GenericParametersAcceptorResolver.php

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public static function resolve(array $argTypes, ParametersAcceptor $parametersAc
123123
$result,
124124
$originalParametersAcceptor->getThrowPoints(),
125125
$originalParametersAcceptor->isPure(),
126+
$originalParametersAcceptor->isDeprecated(),
126127
$originalParametersAcceptor->getImpurePoints(),
127128
$originalParametersAcceptor->getInvalidateExpressions(),
128129
$originalParametersAcceptor->getUsedVariables(),

src/Reflection/InaccessibleMethod.php

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public function isPure(): TrinaryLogic
6262
return TrinaryLogic::createMaybe();
6363
}
6464

65+
public function isDeprecated(): TrinaryLogic
66+
{
67+
return $this->methodReflection->isDeprecated();
68+
}
69+
6570
public function getImpurePoints(): array
6671
{
6772
return [

src/Reflection/ParametersAcceptorSelector.php

+4
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ public static function combineAcceptors(array $acceptors): ExtendedParametersAcc
611611
$callableOccurred = false;
612612
$throwPoints = [];
613613
$isPure = TrinaryLogic::createNo();
614+
$isDeprecated = TrinaryLogic::createNo();
614615
$impurePoints = [];
615616
$invalidateExpressions = [];
616617
$usedVariables = [];
@@ -627,6 +628,7 @@ public static function combineAcceptors(array $acceptors): ExtendedParametersAcc
627628
$callableOccurred = true;
628629
$throwPoints = array_merge($throwPoints, $acceptor->getThrowPoints());
629630
$isPure = $isPure->or($acceptor->isPure());
631+
$isDeprecated = $isDeprecated->or($acceptor->isDeprecated());
630632
$impurePoints = array_merge($impurePoints, $acceptor->getImpurePoints());
631633
$invalidateExpressions = array_merge($invalidateExpressions, $acceptor->getInvalidateExpressions());
632634
$usedVariables = array_merge($usedVariables, $acceptor->getUsedVariables());
@@ -729,6 +731,7 @@ public static function combineAcceptors(array $acceptors): ExtendedParametersAcc
729731
null,
730732
$throwPoints,
731733
$isPure,
734+
$isDeprecated,
732735
$impurePoints,
733736
$invalidateExpressions,
734737
$usedVariables,
@@ -765,6 +768,7 @@ private static function wrapAcceptor(ParametersAcceptor $acceptor): ExtendedPara
765768
TemplateTypeVarianceMap::createEmpty(),
766769
$acceptor->getThrowPoints(),
767770
$acceptor->isPure(),
771+
$acceptor->isDeprecated(),
768772
$acceptor->getImpurePoints(),
769773
$acceptor->getInvalidateExpressions(),
770774
$acceptor->getUsedVariables(),

src/Reflection/ResolvedFunctionVariantWithCallable.php

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct(
2424
private ResolvedFunctionVariant $parametersAcceptor,
2525
private array $throwPoints,
2626
private TrinaryLogic $isPure,
27+
private TrinaryLogic $isDeprecated,
2728
private array $impurePoints,
2829
private array $invalidateExpressions,
2930
private array $usedVariables,
@@ -97,6 +98,11 @@ public function isPure(): TrinaryLogic
9798
return $this->isPure;
9899
}
99100

101+
public function isDeprecated(): TrinaryLogic
102+
{
103+
return $this->isDeprecated;
104+
}
105+
100106
public function getImpurePoints(): array
101107
{
102108
return $this->impurePoints;

src/Reflection/TrivialParametersAcceptor.php

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public function isPure(): TrinaryLogic
7272
return TrinaryLogic::createMaybe();
7373
}
7474

75+
public function isDeprecated(): TrinaryLogic
76+
{
77+
return TrinaryLogic::createNo();
78+
}
79+
7580
public function getImpurePoints(): array
7681
{
7782
return [

src/Rules/RuleLevelHelper.php

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private function transformAcceptedType(Type $acceptingType, Type $acceptedType):
9191
$acceptedType->getResolvedTemplateTypeMap(),
9292
$acceptedType->getTemplateTags(),
9393
$acceptedType->isPure(),
94+
$acceptedType->isDeprecated(),
9495
);
9596
}
9697

src/Type/CallableType.php

+15
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class CallableType implements CompoundType, CallableParametersAcceptor
6565

6666
private TrinaryLogic $isPure;
6767

68+
private TrinaryLogic $isDeprecated;
69+
6870
/**
6971
* @api
7072
* @param list<ParameterReflection>|null $parameters
@@ -78,6 +80,7 @@ public function __construct(
7880
?TemplateTypeMap $resolvedTemplateTypeMap = null,
7981
private array $templateTags = [],
8082
?TrinaryLogic $isPure = null,
83+
?TrinaryLogic $isDeprecated = null,
8184
)
8285
{
8386
$this->parameters = $parameters ?? [];
@@ -86,6 +89,7 @@ public function __construct(
8689
$this->templateTypeMap = $templateTypeMap ?? TemplateTypeMap::createEmpty();
8790
$this->resolvedTemplateTypeMap = $resolvedTemplateTypeMap ?? TemplateTypeMap::createEmpty();
8891
$this->isPure = $isPure ?? TrinaryLogic::createMaybe();
92+
$this->isDeprecated = $isDeprecated ?? TrinaryLogic::createNo();
8993
}
9094

9195
/**
@@ -101,6 +105,14 @@ public function isPure(): TrinaryLogic
101105
return $this->isPure;
102106
}
103107

108+
public function isDeprecated(): TrinaryLogic
109+
{
110+
return $this->isDeprecated;
111+
}
112+
113+
/**
114+
* @return string[]
115+
*/
104116
public function getReferencedClasses(): array
105117
{
106118
$classes = [];
@@ -231,6 +243,7 @@ function (): string {
231243
$this->resolvedTemplateTypeMap,
232244
$this->templateTags,
233245
$this->isPure,
246+
$this->isDeprecated,
234247
);
235248

236249
return $printer->print($selfWithoutParameterNames->toPhpDocNode());
@@ -445,6 +458,7 @@ public function traverse(callable $cb): Type
445458
$this->resolvedTemplateTypeMap,
446459
$this->templateTags,
447460
$this->isPure,
461+
$this->isDeprecated,
448462
);
449463
}
450464

@@ -495,6 +509,7 @@ public function traverseSimultaneously(Type $right, callable $cb): Type
495509
$this->resolvedTemplateTypeMap,
496510
$this->templateTags,
497511
$this->isPure,
512+
$this->isDeprecated,
498513
);
499514
}
500515

src/Type/ClosureType.php

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ public function isPure(): TrinaryLogic
150150
return $certainCount > 0 ? TrinaryLogic::createNo() : TrinaryLogic::createMaybe();
151151
}
152152

153+
public function isDeprecated(): TrinaryLogic
154+
{
155+
return TrinaryLogic::createNo();
156+
}
157+
153158
public function getClassName(): string
154159
{
155160
return $this->objectType->getClassName();

0 commit comments

Comments
 (0)