Skip to content

Commit

Permalink
Fix WrongCaseOfInheritedMethodRule
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 17, 2022
1 parent 6ec99ba commit f6586fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,6 @@ parameters:
count: 1
path: src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php

-
message: "#^Class PHPStan\\\\Rules\\\\Methods\\\\WrongCaseOfInheritedMethodRule implements generic interface PHPStan\\\\Rules\\\\Rule but does not specify its types\\: TNodeType$#"
count: 1
path: src/Rules/Methods/WrongCaseOfInheritedMethodRule.php

-
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\\(\\)$#"
count: 1
path: src/Rules/Methods/WrongCaseOfInheritedMethodRule.php

-
message: "#^Class PHPStan\\\\Rules\\\\Operators\\\\OperandInArithmeticIncrementOrDecrementRule implements generic interface PHPStan\\\\Rules\\\\Rule but does not specify its types\\: TNodeType$#"
count: 1
Expand Down
15 changes: 4 additions & 11 deletions src/Rules/Methods/WrongCaseOfInheritedMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace PHPStan\Rules\Methods;

use PhpParser\Node;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Analyser\Scope;
use PHPStan\Node\InClassMethodNode;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Rules\Rule;
use function sprintf;

/**
* @implements Rule<InClassMethodNode>
*/
class WrongCaseOfInheritedMethodRule implements Rule
{

Expand All @@ -19,20 +20,12 @@ public function getNodeType(): string
return InClassMethodNode::class;
}

/**
* @param ClassMethod $node
* @return string[]
*/
public function processNode(
Node $node,
Scope $scope
): array
{
$methodReflection = $scope->getFunction();
if (!$methodReflection instanceof MethodReflection) {
return [];
}

$methodReflection = $node->getMethodReflection();
$declaringClass = $methodReflection->getDeclaringClass();

$messages = [];
Expand Down

0 comments on commit f6586fa

Please sign in to comment.