Skip to content

Conversation

@TomasVotruba
Copy link
Contributor

@TomasVotruba TomasVotruba commented Oct 27, 2025

This is alternative option to #1125
that does not modify TokenStream, a value object that should be read-only IMO.

To run just this test:

vendor/bin/phpunit test/PhpParser/PrettyPrinterTest.php --filter "args_to"

@nikic Let us know whichever you prefer or if you see a better way to fix this bug 👍

$result .= $this->origTokens->getTokenCode($pos, $endPos + 1, $indentAdjustment);
$tokenCode = $this->origTokens->getTokenCode($pos, $endPos + 1, $indentAdjustment);
if ($node instanceof Expr\CallLike && $node->isFirstClassCallable()) {
$tokenCode = str_replace(',', '', $tokenCode);
Copy link
Contributor

@samsonasik samsonasik Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can use preg_replace() with count arg = 1 to ensure only first , found that removed, see

https://3v4l.org/uZb6m

Suggested change
$tokenCode = str_replace(',', '', $tokenCode);
$tokenCode = preg_replace('/,/', '', $tokenCode, 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants