Skip to content

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Oct 19, 2025

Make use of nikic/PHP-Parser#1113

  • Goal is to verify tests and rules-tests
  • Packages are expected to fail, as they use old patches. Those are not part of testing here.

@TomasVotruba TomasVotruba marked this pull request as draft October 19, 2025 07:51
@TomasVotruba TomasVotruba changed the title tv test php parser dev [poc] Testing native ContaintsStmts interface Oct 19, 2025
Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

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

Also, composer config:

"extra": {
     // ...
     "nikic/php-parser": [

     ],
}

except this line for caching purpose:

https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-nodetraverser-php.patch

can be removed.

@samsonasik
Copy link
Member

For note:

To actually use it, we need to wait for PHPStan new release that consume latest nikic/php-parser that include that feature, then we upping the phpstan/phpstan version.

Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

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

Also, in preload.php and preload-split-package.php or in bootstrap.php, we need BC break check:

class_alias(
    \PhpParser\Node\ContainsStmts::class, 
    \Rector\Contract\PhpParser\Node\StmtsAwareInterface::class
);

then remove the actual Rector\Contract\PhpParser\Node\StmtsAwareInterface class so user that already use it will keep it working :)

Then, create minor release that note user that the interface is deprecated.


There is no actual warning in getNodeTypes() in AbstractRector is not sub type of Node interface, so we only got silent skip operation right now.

@TomasVotruba
Copy link
Member Author

This is just for testing 👍

@samsonasik
Copy link
Member

samsonasik commented Oct 19, 2025

These lines need to be removed

rector-src/composer.json

Lines 119 to 133 in 110cbfa

"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-expr-closure-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-finally-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-function-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-do-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-catch-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-trycatch-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-for-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-classmethod-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-else-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-while-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-foreach-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-if-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-case-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-elseif-php.patch",
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-namespace-php.patch",

to make installation succeed.

Then FileWithoutNamespace need to implements ContaintsStmts as well.

@samsonasik
Copy link
Member

samsonasik commented Oct 19, 2025

I am thinking that StmtsAwareInterface can be kept for a while, and make it extends PhpParser\Node\ContainsStmts:

-interface StmtsAwareInterface extends Node
+/** @deprecated use \PhpParser\Node\ContaintsStmts instead */
+interface StmtsAwareInterface extends Node\ContaintsStmts

@samsonasik
Copy link
Member

samsonasik commented Oct 19, 2025

@samsonasik
Copy link
Member

@TomasVotruba please rebase, unit tests should green now 👍

@TomasVotruba TomasVotruba force-pushed the tv-test-php-parser-dev branch from 59576e4 to 1e31208 Compare October 19, 2025 16:25
@TomasVotruba TomasVotruba deleted the tv-test-php-parser-dev branch October 19, 2025 16:38
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