rector-src icon indicating copy to clipboard operation
rector-src copied to clipboard

Try php-parser:dev-master (5-dev)

Open samsonasik opened this issue 3 years ago • 6 comments

This is just to see possible upgrade needed when use php-parser 5, beside looking on changelog, as php-parser 5 is based on dev-master

samsonasik avatar Sep 07 '22 01:09 samsonasik

The vendor-patches error is due to class Closure movement from Expr to below Node directly.


  - Applying patches for nikic/php-parser
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-expr-closure-php.patch (0)
   Could not apply patch! Skipping. The error was: Cannot apply patch 
https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-expr-closure-php.patch

Error: Cannot apply patch 0 (https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-expr-closure-php.patch)!

In Patches.php line 326:
                                                                               
  Cannot apply patch 0 (
https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-expr-closure-php.pat  

samsonasik avatar Sep 07 '22 01:09 samsonasik

It seems for Closure change, the change is on placing { on the right:

https://github.com/rectorphp/vendor-patches/commit/3e279f85ee049662385baa8ca9719d90ed58f846

samsonasik avatar Sep 07 '22 02:09 samsonasik

The php-parser dev-master with vendor-patch is now installable, the preload config seems needs update:

➜  rector-src git:(try-php-parser-master) php build/build-preload.php .
➜  rector-src git:(try-php-parser-master) ✗ php preload.php 
PHP Fatal error:  Cannot declare class PhpParser\Node\ArrayItem, because the name is already in use in /Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php on line 7

Fatal error: Cannot declare class PhpParser\Node\ArrayItem, because the name is already in use in /Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php on line 7

samsonasik avatar Sep 07 '22 02:09 samsonasik

@TomasVotruba I updated vendor-patches to make php-parser dev-master (5-dev) installable.

@ondrejmirtes I updated preload.php for handling movement of various Node Stmt/Expr to under Node directly, the following error seems require update in PHPStan side for update:

Run php ../e2eTestRunner.php
PHP Fatal error:  Class PHPStan\Parser\PhpParserDecorator contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PhpParser\Parser::getLexer) in phar:///home/runner/work/rector-src/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Parser/PhpParserDecorator.php on line 11
Fatal error: Class PHPStan\Parser\PhpParserDecorator contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PhpParser\Parser::getLexer) in phar:///home/runner/work/rector-src/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Parser/PhpParserDecorator.php on line 11

see https://github.com/rectorphp/rector-src/runs/8220121936?check_suite_focus=true#step:8:9

samsonasik avatar Sep 07 '22 03:09 samsonasik

Im watching the progress with excitement... keep it going 😊

TomasVotruba avatar Sep 07 '22 11:09 TomasVotruba

Rebased and regenerate preload files https://github.com/rectorphp/rector-src/pull/2916/commits/705cffba522a40d4ca99ea1e192b06ff9bdd6274

samsonasik avatar Nov 15 '22 19:11 samsonasik

Thanks for the probe :+1: Closing for now, untill the php-parser 5 is released with PHPStan onboard and we can finish it easily.

TomasVotruba avatar Nov 18 '22 21:11 TomasVotruba