Skip to content

Commit

Permalink
Modernized IncompatibleDefaultParameterTypeRule
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 25, 2023
1 parent b909b3a commit a79ad03
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/Rules/Functions/IncompatibleDefaultParameterTypeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PHPStan\Analyser\Scope;
use PHPStan\Node\InFunctionNode;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Reflection\Php\PhpFunctionFromParserNodeReflection;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\ShouldNotHappenException;
Expand All @@ -28,10 +27,7 @@ public function getNodeType(): string

public function processNode(Node $node, Scope $scope): array
{
$function = $scope->getFunction();
if (!$function instanceof PhpFunctionFromParserNodeReflection) {
return [];
}
$function = $node->getFunctionReflection();
$parameters = ParametersAcceptorSelector::selectSingle($function->getVariants());

$errors = [];
Expand Down
7 changes: 1 addition & 6 deletions src/Rules/Methods/IncompatibleDefaultParameterTypeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PHPStan\Analyser\Scope;
use PHPStan\Node\InClassMethodNode;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Reflection\Php\PhpMethodFromParserNodeReflection;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\ShouldNotHappenException;
Expand All @@ -28,11 +27,7 @@ public function getNodeType(): string

public function processNode(Node $node, Scope $scope): array
{
$method = $scope->getFunction();
if (!$method instanceof PhpMethodFromParserNodeReflection) {
return [];
}

$method = $node->getMethodReflection();
$parameters = ParametersAcceptorSelector::selectSingle($method->getVariants());

$errors = [];
Expand Down

0 comments on commit a79ad03

Please # to comment.