Skip to content

[compat] Resolve preloading of stmts interface crashing in PHPUnit 12 and in PHPStan + Rector test suite #9416

@TomasVotruba

Description

@TomasVotruba

This is a meta issue to focus on solving tests crashing on PHPUnit 12 and related php-parser preload issues.

At the moment, we patch php-parser in our /vendor to allow single interface to ~10 nodes that use $stmts.
We can use signle type to iterate on all stmts, instead of explicitly using these 10.

I opened PR to allow this in a php-parser core, but it didn't get far: nikic/PHP-Parser#836
So I patched vendor. Not the best solution, but with preload it worked for couple of years: https://github.com/rectorphp/vendor-patches

Now PHPUnit 12.2 introduced preload if its own vendor php-parser first: #9401
And this triggered a new round of issues. https://github.com/rectorphp/rector/issues?q=phpunit+12

There is no will to fix this in PHPUnit (sebastianbergmann/phpunit#6381), so we can either let tests crash, or fix it by going back to listing of all stmts nodes explicitly. It will be bit more verbose on our side, but community tests will work.


The imminent step is: removing vendor patches of php-parser.

Then as following, I see 2 options:

  • add a new PR to php-parser with stmts interface without ClassMethod and hope it passes, that would resolve all our problems as feature we need would be in php-parser core - might take some time and its seems as not welcomed at the moment
  • go back to full listing of nodes that contain $stmts - quick, just works and we can handle it ourselves

Feedback and practical solutions are welcomed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions