Skip to content

Commit f6586fa

Browse files
committed
Fix WrongCaseOfInheritedMethodRule
1 parent 6ec99ba commit f6586fa

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

Diff for: phpstan-baseline.neon

-10
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,6 @@ parameters:
102102
count: 1
103103
path: src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php
104104

105-
-
106-
message: "#^Class PHPStan\\\\Rules\\\\Methods\\\\WrongCaseOfInheritedMethodRule implements generic interface PHPStan\\\\Rules\\\\Rule but does not specify its types\\: TNodeType$#"
107-
count: 1
108-
path: src/Rules/Methods/WrongCaseOfInheritedMethodRule.php
109-
110-
-
111-
message: "#^Parameter \\#1 \\$node \\(PhpParser\\\\Node\\\\Stmt\\\\ClassMethod\\) of method PHPStan\\\\Rules\\\\Methods\\\\WrongCaseOfInheritedMethodRule\\:\\:processNode\\(\\) should be contravariant with parameter \\$node \\(PhpParser\\\\Node\\) of method PHPStan\\\\Rules\\\\Rule\\<PhpParser\\\\Node\\>\\:\\:processNode\\(\\)$#"
112-
count: 1
113-
path: src/Rules/Methods/WrongCaseOfInheritedMethodRule.php
114-
115105
-
116106
message: "#^Class PHPStan\\\\Rules\\\\Operators\\\\OperandInArithmeticIncrementOrDecrementRule implements generic interface PHPStan\\\\Rules\\\\Rule but does not specify its types\\: TNodeType$#"
117107
count: 1

Diff for: src/Rules/Methods/WrongCaseOfInheritedMethodRule.php

+4-11
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
namespace PHPStan\Rules\Methods;
44

55
use PhpParser\Node;
6-
use PhpParser\Node\Stmt\ClassMethod;
76
use PHPStan\Analyser\Scope;
87
use PHPStan\Node\InClassMethodNode;
98
use PHPStan\Reflection\ClassReflection;
10-
use PHPStan\Reflection\MethodReflection;
119
use PHPStan\Rules\Rule;
1210
use function sprintf;
1311

12+
/**
13+
* @implements Rule<InClassMethodNode>
14+
*/
1415
class WrongCaseOfInheritedMethodRule implements Rule
1516
{
1617

@@ -19,20 +20,12 @@ public function getNodeType(): string
1920
return InClassMethodNode::class;
2021
}
2122

22-
/**
23-
* @param ClassMethod $node
24-
* @return string[]
25-
*/
2623
public function processNode(
2724
Node $node,
2825
Scope $scope
2926
): array
3027
{
31-
$methodReflection = $scope->getFunction();
32-
if (!$methodReflection instanceof MethodReflection) {
33-
return [];
34-
}
35-
28+
$methodReflection = $node->getMethodReflection();
3629
$declaringClass = $methodReflection->getDeclaringClass();
3730

3831
$messages = [];

0 commit comments

Comments
 (0)