Skip to content

Commit 977f2b4

Browse files
committed
[BCB] Remove FunctionReflection::isFinal()
1 parent b1ea97a commit 977f2b4

12 files changed

+15
-68
lines changed

UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,4 @@ Instead of `PHPStanTestCase::createBroker()`, call `PHPStanTestCase::createRefle
277277
* Parameter `$nextAutoIndexes` in `ConstantArrayType` constructor can only be `non-empty-list<int>`, no longer int
278278
* Remove `ConstantType` interface, use [`Type::isConstantValue()`](https://apiref.phpstan.org/2.0.x/PHPStan.Type.Type.html#_isConstantValue) instead
279279
* `acceptsNamedArguments()` in `FunctionReflection`, `ExtendedMethodReflection` and `CallableParametersAcceptor` interfaces returns `TrinaryLogic` instead of `bool`
280+
* Remove `FunctionReflection::isFinal()`

src/Analyser/MutatingScope.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,7 +3075,6 @@ public function enterFunction(
30753075
?string $deprecatedDescription,
30763076
bool $isDeprecated,
30773077
bool $isInternal,
3078-
bool $isFinal,
30793078
?bool $isPure = null,
30803079
bool $acceptsNamedArguments = true,
30813080
?Assertions $asserts = null,
@@ -3099,7 +3098,6 @@ public function enterFunction(
30993098
$deprecatedDescription,
31003099
$isDeprecated,
31013100
$isInternal,
3102-
$isFinal,
31033101
$isPure,
31043102
$acceptsNamedArguments,
31053103
$asserts ?? Assertions::createEmpty(),

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ private function processStmtNode(
513513
$throwPoints = [];
514514
$impurePoints = [];
515515
$this->processAttributeGroups($stmt, $stmt->attrGroups, $scope, $nodeCallback);
516-
[$templateTypeMap, $phpDocParameterTypes, $phpDocImmediatelyInvokedCallableParameters, $phpDocClosureThisTypeParameters, $phpDocReturnType, $phpDocThrowType, $deprecatedDescription, $isDeprecated, $isInternal, $isFinal, $isPure, $acceptsNamedArguments, , $phpDocComment, $asserts,, $phpDocParameterOutTypes] = $this->getPhpDocs($scope, $stmt);
516+
[$templateTypeMap, $phpDocParameterTypes, $phpDocImmediatelyInvokedCallableParameters, $phpDocClosureThisTypeParameters, $phpDocReturnType, $phpDocThrowType, $deprecatedDescription, $isDeprecated, $isInternal, , $isPure, $acceptsNamedArguments, , $phpDocComment, $asserts,, $phpDocParameterOutTypes] = $this->getPhpDocs($scope, $stmt);
517517

518518
foreach ($stmt->params as $param) {
519519
$this->processParamNode($stmt, $param, $scope, $nodeCallback);
@@ -532,7 +532,6 @@ private function processStmtNode(
532532
$deprecatedDescription,
533533
$isDeprecated,
534534
$isInternal,
535-
$isFinal,
536535
$isPure,
537536
$acceptsNamedArguments,
538537
$asserts,

src/Reflection/FunctionReflection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public function isDeprecated(): TrinaryLogic;
3434

3535
public function getDeprecatedDescription(): ?string;
3636

37-
public function isFinal(): TrinaryLogic;
38-
3937
public function isInternal(): TrinaryLogic;
4038

4139
public function getThrowType(): ?Type;

src/Reflection/Native/NativeFunctionReflection.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ public function isInternal(): TrinaryLogic
8888
return TrinaryLogic::createNo();
8989
}
9090

91-
public function isFinal(): TrinaryLogic
92-
{
93-
return TrinaryLogic::createNo();
94-
}
95-
9691
public function hasSideEffects(): TrinaryLogic
9792
{
9893
if ($this->isVoid()) {

src/Reflection/Php/ExitFunctionReflection.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ public function getDeprecatedDescription(): ?string
9797
return null;
9898
}
9999

100-
public function isFinal(): TrinaryLogic
101-
{
102-
return TrinaryLogic::createNo();
103-
}
104-
105100
public function isInternal(): TrinaryLogic
106101
{
107102
return TrinaryLogic::createYes();

src/Reflection/Php/PhpFunctionFromParserNodeReflection.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public function __construct(
5858
private ?string $deprecatedDescription,
5959
private bool $isDeprecated,
6060
private bool $isInternal,
61-
private bool $isFinal,
6261
protected ?bool $isPure,
6362
private bool $acceptsNamedArguments,
6463
private Assertions $assertions,
@@ -235,24 +234,6 @@ public function isInternal(): TrinaryLogic
235234
return TrinaryLogic::createFromBoolean($this->isInternal);
236235
}
237236

238-
public function isFinal(): TrinaryLogic
239-
{
240-
$finalMethod = false;
241-
if ($this->functionLike instanceof ClassMethod) {
242-
$finalMethod = $this->functionLike->isFinal();
243-
}
244-
return TrinaryLogic::createFromBoolean($finalMethod || $this->isFinal);
245-
}
246-
247-
public function isFinalByKeyword(): TrinaryLogic
248-
{
249-
$finalMethod = false;
250-
if ($this->functionLike instanceof ClassMethod) {
251-
$finalMethod = $this->functionLike->isFinal();
252-
}
253-
return TrinaryLogic::createFromBoolean($finalMethod);
254-
}
255-
256237
public function getThrowType(): ?Type
257238
{
258239
return $this->throwType;

src/Reflection/Php/PhpFunctionReflection.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ public function isInternal(): TrinaryLogic
249249
return TrinaryLogic::createFromBoolean($this->isInternal);
250250
}
251251

252-
public function isFinal(): TrinaryLogic
253-
{
254-
return TrinaryLogic::createFromBoolean($this->isFinal);
255-
}
256-
257252
public function getThrowType(): ?Type
258253
{
259254
return $this->phpDocThrowType;

src/Reflection/Php/PhpMethodFromParserNodeReflection.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class PhpMethodFromParserNodeReflection extends PhpFunctionFromParserNodeR
3838
*/
3939
public function __construct(
4040
private ClassReflection $declaringClass,
41-
ClassMethod $classMethod,
41+
private ClassMethod $classMethod,
4242
string $fileName,
4343
TemplateTypeMap $templateTypeMap,
4444
array $realParameterTypes,
@@ -50,7 +50,7 @@ public function __construct(
5050
?string $deprecatedDescription,
5151
bool $isDeprecated,
5252
bool $isInternal,
53-
bool $isFinal,
53+
private bool $isFinal,
5454
?bool $isPure,
5555
bool $acceptsNamedArguments,
5656
Assertions $assertions,
@@ -107,7 +107,6 @@ public function __construct(
107107
$deprecatedDescription,
108108
$isDeprecated,
109109
$isInternal,
110-
$isFinal || $classMethod->isFinal(),
111110
$isPure,
112111
$acceptsNamedArguments,
113112
$assertions,
@@ -154,6 +153,16 @@ public function isPublic(): bool
154153
return $this->getClassMethod()->isPublic();
155154
}
156155

156+
public function isFinal(): TrinaryLogic
157+
{
158+
return TrinaryLogic::createFromBoolean($this->classMethod->isFinal() || $this->isFinal);
159+
}
160+
161+
public function isFinalByKeyword(): TrinaryLogic
162+
{
163+
return TrinaryLogic::createFromBoolean($this->classMethod->isFinal());
164+
}
165+
157166
public function isBuiltin(): bool
158167
{
159168
return false;

tests/PHPStan/Reflection/Annotations/FinalAnnotationsTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use FinalAnnotations\FinalFoo;
66
use FinalAnnotations\Foo;
7-
use PhpParser\Node\Name;
87
use PHPStan\Analyser\Scope;
98
use PHPStan\Testing\PHPStanTestCase;
109

@@ -58,14 +57,4 @@ public function testFinalAnnotations(bool $final, string $className, array $fina
5857
}
5958
}
6059

61-
public function testFinalUserFunctions(): void
62-
{
63-
require_once __DIR__ . '/data/annotations-final.php';
64-
65-
$reflectionProvider = $this->createReflectionProvider();
66-
67-
$this->assertFalse($reflectionProvider->getFunction(new Name\FullyQualified('FinalAnnotations\foo'), null)->isFinal()->yes());
68-
$this->assertTrue($reflectionProvider->getFunction(new Name\FullyQualified('FinalAnnotations\finalFoo'), null)->isFinal()->yes());
69-
}
70-
7160
}

0 commit comments

Comments
 (0)