Skip to content

Commit

Permalink
Merge pull request #834 from sebdesign/passable-by-reference-first-cl…
Browse files Browse the repository at this point in the history
…ass-callable
  • Loading branch information
bobthecow authored Nov 18, 2024
2 parents 5c19690 + c548419 commit 202f2e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/CodeCleaner/PassableByReferencePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\VariadicPlaceholder;
use Psy\Exception\FatalErrorException;

/**
Expand Down Expand Up @@ -61,6 +62,10 @@ public function enterNode(Node $node)

$args = [];
foreach ($node->args as $position => $arg) {
if ($arg instanceof VariadicPlaceholder) {
continue;
}

$args[$arg->name !== null ? $arg->name->name : $position] = $arg;
}

Expand Down
4 changes: 4 additions & 0 deletions test/CodeCleaner/PassableByReferencePassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public function validStatements()
$values[] = ['preg_match(\'/\d+/\', \'123456\', offset: 2)'];
}

if (\version_compare(\PHP_VERSION, '8.1', '>=')) {
$values[] = ['intval(...)'];
}

return $values;
}

Expand Down

0 comments on commit 202f2e8

Please sign in to comment.