Skip to content

Conversation

@samsonasik
Copy link
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
Member Author

/cc @calebdw

@samsonasik
Copy link
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
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
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
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

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.

3 participants