Skip to content

Commit

Permalink
10% faster FunctionCallParametersCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Dec 16, 2024
1 parent edc13ad commit 2d64686
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Rules/FunctionCallParametersCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public function check(
$hasNamedArguments = false;
$hasUnpackedArgument = false;
$errors = [];
foreach ($args as $i => $arg) {
$type = $scope->getType($arg->value);
foreach ($args as $arg) {
if ($hasNamedArguments && $arg->unpack) {
$errors[] = RuleErrorBuilder::message('Named argument cannot be followed by an unpacked (...) argument.')
->identifier('argument.unpackAfterNamed')
Expand All @@ -113,6 +112,7 @@ public function check(
$argumentName = $arg->name->toString();
}
if ($arg->unpack) {
$type = $scope->getType($arg->value);
$arrays = $type->getConstantArrays();
if (count($arrays) > 0) {
$minKeys = null;
Expand Down Expand Up @@ -191,7 +191,7 @@ public function check(

if (!$hasNamedArguments) {
$invokedParametersCount = count($arguments);
foreach ($arguments as $i => [$argumentValue, $argumentValueType, $unpack, $argumentName]) {
foreach ($arguments as [$argumentValue, $argumentValueType, $unpack, $argumentName]) {
if ($unpack) {
$invokedParametersCount = max($functionParametersMinCount, $functionParametersMaxCount);
break;
Expand Down

0 comments on commit 2d64686

Please sign in to comment.