Problem with nikic/php-parser replaced dependency
mdeboer opened this issue · 4 comments
I have a production dependency which in turn depends on nikic/php-parser. Without installing phpstan-shim this works fine when I run composer install --no-dev to exclude dev dependencies. However when I add phpstan-shim to my dev dependencies and run composer install --no-dev, the nikic/php-parser dependency is not installed.
This might be a bug in composer as phpstan-shim is a dev dependency and thus its replace rule should never be loaded when installing without dev dependencies.
To sum it up:
- without phpstan-shim = all fine (both dev and no-dev)
- with phpstan-shim in dev = all fine
- with phpstan-shim in dev (with
--no-dev) = installs without warning but does not install nikic/php-parser
However, I wonder why nikic/php-parser is referenced at all?
nikic/php-parser is referenced so that PHPStan extensions can work with the shim.
To sum up your issue: You have nikic/php-parser in your require section and phpstan-shim in your require-dev section. When you composer install --no-dev, neither nikic/php-parser nor phpstan-shim gets installed. Am I right?
Correct, altough nikic/php-parser is a require dependency of one of my require dependencies, so it's not a direct dependency.
However when debugging I also tested with requiring nikic/php-parser as a direct dependency but with the same results.
I ended up downloading the phar myself as I don't use any extensions.
I think it would be best if you created a small repo with reproduction of this problem and submitted it as a Composer issue. I'm interested in it so please link it here afterwards.
This weekend I'll have a look and submit it as a composer issue. Pretty confident I can reproduce it quite easily.