Skip to content

Commit

Permalink
Early return false after VariadicPlaceholder check on CallLike::isFir…
Browse files Browse the repository at this point in the history
…stClassCallable() (#924)

VariadicPlaceholder can only occur as the first (and only) argument, so avoid a loop to check for it.
  • Loading branch information
samsonasik committed Jun 25, 2023
1 parent 3fb4b92 commit eaa1d91
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/PhpParser/Node/Expr/CallLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ abstract public function getRawArgs(): array;
* Returns whether this call expression is actually a first class callable.
*/
public function isFirstClassCallable(): bool {
foreach ($this->getRawArgs() as $arg) {
if ($arg instanceof VariadicPlaceholder) {
return true;
}
}
return false;
$rawArgs = $this->getRawArgs();
return count($rawArgs) === 1 && current($rawArgs) instanceof VariadicPlaceholder;
}

/**
Expand Down

0 comments on commit eaa1d91

Please sign in to comment.