Skip to content

[Printer] Fixture crash on named argument usage on array_map() due to unpack arg flipped#7399

Closed
samsonasik wants to merge 2 commits into
mainfrom
try-crash
Closed

[Printer] Fixture crash on named argument usage on array_map() due to unpack arg flipped#7399
samsonasik wants to merge 2 commits into
mainfrom
try-crash

Conversation

@samsonasik
Copy link
Copy Markdown
Member

Given the following code:

final class IncludeArrayMapNamed
{
    /**
     * @param int[] $items
     */
    public function run(array $items)
    {
        $result = array_map(array: $items, callback: fn ($item) => $item * 2);
    }
}

It currently got crash:

There was 1 failure:

1) Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayFunctionClosureParamTypeRector\AddArrayFunctionClosureParamTypeRectorTest::test with data set #3 ('/Users/samsonasik/www/rector-...hp.inc')
assert($itemStartPos >= 0 && $itemEndPos >= 0 && $itemStartPos >= $pos)

/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php:842
/Users/samsonasik/www/rector-src/src/PhpParser/Printer/BetterStandardPrinter.php:281

Linked to php-parser getArg() method

@samsonasik
Copy link
Copy Markdown
Member Author

/cc @calebdw

@samsonasik
Copy link
Copy Markdown
Member Author

The issue seems on Printer itself, so nothing todo with getArg(),

@samsonasik samsonasik marked this pull request as draft October 2, 2025 15:10
@samsonasik samsonasik changed the title [TypeDeclaration] Fixture crash on named argument with getArg() usage on array_map() due to unpack arg [TypeDeclaration] Fixture crash on named argument usage on array_map() due to unpack arg flipped Oct 2, 2025
@samsonasik samsonasik changed the title [TypeDeclaration] Fixture crash on named argument usage on array_map() due to unpack arg flipped [Printer] Fixture crash on named argument usage on array_map() due to unpack arg flipped Oct 2, 2025
@samsonasik
Copy link
Copy Markdown
Member Author

samsonasik commented Oct 2, 2025

If it know about the information on named argument and its unpacked on print, it seems the issue on Internal PHPStan printer...

@samsonasik
Copy link
Copy Markdown
Member Author

Closing for now as seems unrelated with rector, possibly on phpstan/php-parser internal side, as without getArg() call, the crash still happen on printing.

@samsonasik samsonasik closed this Oct 2, 2025
@samsonasik samsonasik deleted the try-crash branch October 2, 2025 15:35
@calebdw
Copy link
Copy Markdown
Contributor

calebdw commented Oct 2, 2025

The issue seems on Printer itself, so nothing todo with getArg(),

That was my initial suspicion from looking at it

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants