rector: [Install] Conflict with PHP-Parser
Recently, I tried to use Rector with Siler. As Siler requires PHPStan, and PHPStan in its turn requires PHP-Parser v3, I got an conflict:
PHP Fatal error: Declaration of PhpParser\Node\Stmt\PropertyProperty::getSubNodeNames() must be compatible with PhpParser\Node::getSubNodeNames(): array in /var/www/siler/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php on line 30
I tried to solve it, but when looking into rector_bootstrap.php, I find out that the $possibleAutoloadPaths are the same:
$possibleAutoloadPaths = [
// repository
__DIR__ . '/../vendor/autoload.php',
// composer create-project
__DIR__ . '/../vendor/autoload.php',
// composer require
__DIR__ . '/../../../../vendor/autoload.php',
];
I first try to require it:
composer require --dev rector/rector 'dev-master' nikic/php-parser '4.0.x-dev'
And got the versions conflict.
Then tried to use my version of:
composer create-project rector/rector:'dev-master' path-to-rector
And find out this conflict.
@TomasVotruba How should we solve it? I know that is one more issue, but I couldn’t figure out how 😞
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 27 (24 by maintainers)
Commits related to this issue
- README: add development phase + remove create-project note (not practical) — committed to rectorphp/rector by TomasVotruba 6 years ago
- README: add conflict install recommendation, ref #258 — committed to rectorphp/rector by TomasVotruba 6 years ago
- Updated Rector to commit 88559e002b588102ef53cb49803db4283fe304b9 https://github.com/rectorphp/rector-src/commit/88559e002b588102ef53cb49803db4283fe304b9 [Doc] Add comment @see for move method call t... — committed to rectorphp/rector by TomasVotruba 3 years ago
- [Doc] Add comment @see for move method call to assign outside loop (#258) — committed to echo511/rector by samsonasik 3 years ago
👍
Also if you want a more complete list of possible solutions I recommend you this article 😃
Yes, sorry, fixed. I tried to mention that to remove this conflict solution we will need to wait until that 😅
Now it is as part of BetterReflection: https://github.com/rectorphp/rector/blob/8fca502b51d90809eab34ac608c3feffaef6abab/packages/BetterReflection/src/SourceLocator/SourceLocatorFactory.php#L93
But thanks to the new solution, we could move away from this. BetterReflection is the slowest component here and aims on not-autoloading classes, which brings no value to this projects, because it basically ends up parsing whole
/vendordirectory.Oups missed that
I either recommend PHARs (isolated if executes code) or the approach with bamarni. If you don’t want to think too much about it I would recommend the bamarni approach as the other ones requires a bit more thinking for keeping track of the PHAR and if the PHAR is not isolated it can require some work for it…
TL:DR; the approach you suggested is perfectly fine, I use it extensively
@theofidry I know, I linked it above 😃 If you read this issue, do you suggest something better to use for this project?
Thanks a lot for the post btw! We looked for solution for this for over a month now
@OndraM I guess there’s nothing to do with PHPStan, I’m really sorry to bore you with it. Everything that we should do now is to wait for
PHP-Parserhits version 4, and we can upgrade PHPStan. So we can ensure that Rector runs on applications that require PHPStan inrequire-devsection.There are 2 ways how to solve this:
composer create-project rector/rector ...which keeps rector’s dependencies out of project scope