Too restrictive composer.json version requirements for nikic/php-parser
d42ohpaz opened this issue · 3 comments
Both the develop
and master
composer.json
use the ^
to restrict nikic/php-parser
to a single major version. This is problematic as php-parser
is one major version ahead of develop
and three major versions ahead of master
. Does this package not work on newer versions?
The use-case for this ticket is that I am building a jenkins CI environment, and I'm using ramsey/jenkins-php
to install the various tools I plan to use. It depends on phpdocumentor/phpdocumentor 2.8
, which depends on phpdocumentor/reflection ^3.0
, which depends on nikic/php-parser ^1.0
.
When I try to install phpstan/phpstan-symfony
, which depends on nikic/php-parser ^4.0
, it fails because nikic/php-parser ^1.0
is already installed:
[root@localhost ~]# /usr/local/bin/composer global require phpstan/phpstan-symfony
Changed current directory to /root/.composer
Using version ^0.10.1 for phpstan/phpstan-symfony
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for phpstan/phpstan-symfony ^0.10.1 -> satisfiable by phpstan/phpstan-symfony[0.10.1].
- Conclusion: remove nikic/php-parser v1.4.1
- Conclusion: don't install nikic/php-parser v1.4.1
- phpstan/phpstan-symfony 0.10.1 requires nikic/php-parser ^4.0 -> satisfiable by nikic/php-parser[v4.0.0, v4.0.1, v4.0.2, v4.0.3].
- Can only install one of: nikic/php-parser[v4.0.0, v1.4.1].
- Can only install one of: nikic/php-parser[v4.0.1, v1.4.1].
- Can only install one of: nikic/php-parser[v4.0.2, v1.4.1].
- Can only install one of: nikic/php-parser[v4.0.3, v1.4.1].
- Installation request for nikic/php-parser (locked at v1.4.1) -> satisfiable by nikic/php-parser[v1.4.1].
Installation failed, reverting ./composer.json to its original content.
Would it not be more preferable to use a constraint such as >=1.0.0
(master
) and >=3.0.0
(develop
)?
At this juncture, I feel stuck between a rock and a hard place in having to decide between two equally needed tools for my CI environment.
As a side note, I will also be reaching out to phpstan/phpstan-symfony
about their usage of the ^
version constraint as well.
PHP Parser doesn't play games with the term 'major version'; so far every major version has had backwards breaking changes big enough to make phpDocumentor unusable. Restricting unto a major version is necessary to ensure phpDocumentor works. Mind you, this is not just phpDocumentor; any tool using PHP-Parser would not have the flexibility that you desire
beside that we and phpstan do both provide a phar file it cover issues like this one. I would highly recommend you to have a look at https://phar.io/ which is an upcomming packagemanager for php applications like phpstan phpunit and phpdocumentor.
That said I just create a pr #128 to support v4 of php-parser in develop. However that will not help you with this conflict. The v4 release of this package will not be supported by phpdocumentor v2.