Skip to content

Commit 5dc3143

Browse files
committed
Introduce isDeprecated to CallableParametersAcceptor
1 parent 46b9819 commit 5dc3143

14 files changed

+83
-1
lines changed

src/Analyser/MutatingScope.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,7 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
13421342
$cachedClosureData['invalidateExpressions'],
13431343
$cachedClosureData['usedVariables'],
13441344
TrinaryLogic::createYes(),
1345+
TrinaryLogic::createNo(),
13451346
);
13461347
}
13471348
if (self::$resolveClosureTypeDepth >= 2) {
@@ -1557,6 +1558,7 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
15571558
$invalidateExpressions,
15581559
$usedVariables,
15591560
TrinaryLogic::createYes(),
1561+
TrinaryLogic::createNo(),
15601562
);
15611563
} elseif ($node instanceof New_) {
15621564
if ($node->class instanceof Name) {
@@ -2552,6 +2554,7 @@ private function createFirstClassCallable(
25522554
[],
25532555
[],
25542556
$acceptsNamedArguments,
2557+
$variant->isDeprecated(),
25552558
);
25562559
}
25572560

src/Reflection/Callables/CallableParametersAcceptor.php

Lines changed: 2 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

@@ -112,6 +113,7 @@ private function transformAcceptedType(Type $acceptingType, Type $acceptedType):
112113
$acceptedType->getInvalidateExpressions(),
113114
$acceptedType->getUsedVariables(),
114115
$acceptedType->acceptsNamedArguments(),
116+
$acceptedType->isDeprecated(),
115117
);
116118
}
117119

0 commit comments

Comments
 (0)