Skip to content

Commit

Permalink
Fix variadic parameter after optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 10, 2020
1 parent 4033321 commit 287b8b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rules/FunctionDefinitionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ private function checkRequiredParameterAfterOptional(array $parameterNodes): arr
throw new \PHPStan\ShouldNotHappenException();
}
$parameterName = $parameterNode->var->name;
if ($optionalParameter !== null && $parameterNode->default === null) {
if ($optionalParameter !== null && $parameterNode->default === null && !$parameterNode->variadic) {
$errors[] = RuleErrorBuilder::message(sprintf('Deprecated in PHP 8.0: Required parameter $%s follows optional parameter $%s.', $parameterName, $optionalParameter))->line($parameterNode->getStartLine())->nonIgnorable()->build();
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ function doBaz(int $foo = 1, $bar): void // not OK
function doLorem(bool $foo = true, $bar): void // not OK
{
}

function doIpsum(bool $foo = true, ...$bar): void // OK
{
}

0 comments on commit 287b8b8

Please sign in to comment.