Skip to content

Commit a79ad03

Browse files
committed
Modernized IncompatibleDefaultParameterTypeRule
1 parent b909b3a commit a79ad03

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

Diff for: src/Rules/Functions/IncompatibleDefaultParameterTypeRule.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Node\InFunctionNode;
88
use PHPStan\Reflection\ParametersAcceptorSelector;
9-
use PHPStan\Reflection\Php\PhpFunctionFromParserNodeReflection;
109
use PHPStan\Rules\Rule;
1110
use PHPStan\Rules\RuleErrorBuilder;
1211
use PHPStan\ShouldNotHappenException;
@@ -28,10 +27,7 @@ public function getNodeType(): string
2827

2928
public function processNode(Node $node, Scope $scope): array
3029
{
31-
$function = $scope->getFunction();
32-
if (!$function instanceof PhpFunctionFromParserNodeReflection) {
33-
return [];
34-
}
30+
$function = $node->getFunctionReflection();
3531
$parameters = ParametersAcceptorSelector::selectSingle($function->getVariants());
3632

3733
$errors = [];

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Node\InClassMethodNode;
88
use PHPStan\Reflection\ParametersAcceptorSelector;
9-
use PHPStan\Reflection\Php\PhpMethodFromParserNodeReflection;
109
use PHPStan\Rules\Rule;
1110
use PHPStan\Rules\RuleErrorBuilder;
1211
use PHPStan\ShouldNotHappenException;
@@ -28,11 +27,7 @@ public function getNodeType(): string
2827

2928
public function processNode(Node $node, Scope $scope): array
3029
{
31-
$method = $scope->getFunction();
32-
if (!$method instanceof PhpMethodFromParserNodeReflection) {
33-
return [];
34-
}
35-
30+
$method = $node->getMethodReflection();
3631
$parameters = ParametersAcceptorSelector::selectSingle($method->getVariants());
3732

3833
$errors = [];

0 commit comments

Comments
 (0)