composer-installer: Plugin not working correctly when sniffs install depth is equal to "1"

Problem/Motivation

Since I use the “*” constraint in our projects, the package updated to 0.3.0 today. Right now, the default PHPCompatiblity sniff can not be found. I have not yet looked into it myself in the hope that you might know right away what the issue is.

Expected behaviour

PHPComptability sniff should still be installed

$ ./vendor/bin/phpcs -i
The installed coding standards are Zend, PHPCS, MySource, PSR2, PEAR, PSR1, Squiz and PHPCompatibility

Actual behaviour

Sniff is not installed:

$ vendor/bin/phpcs -i
The installed coding standards are Zend, PHPCS, MySource, PSR2, PEAR, PSR1 and Squiz

Steps to reproduce

composer.json:

  "require-dev": {
    "squizlabs/php_codesniffer": "^2",
    "dealerdirect/phpcodesniffer-composer-installer": "*",
    "frenck/php-compatibility": "*"
  }

Delete vendor folder (if 0.2.1 which still works was installed, the sniff is still there)

$ composer update
$ vendor/bin/phpcs 
$ ./vendor/bin/phpcs --standard=PHPCompatibility --extensions=php ./src
$ ./vendor/bin/phpcs -i

Proposed changes

Is there a migration I missed or needs frenck/PHPCompatibility a new version too?

Thanks in advance for any help.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (13 by maintainers)

Commits related to this issue

Most upvoted comments

We also upgraded to 0.3.1 and it’s working. Thanks!

@frenck Just tested it in one of our projects, works! Thanks for the fix!

Sadly, the workaround did not work for me, neither for the update nor a clean install so I had a look at the plugin.

What I found:

After a clean install, the installedPaths are empty. The “frenck/php-compatibility” package is found by getPHPCodingStandardPackages() but since the Finder in updateInstalledPaths() sets the depth to >1 (which is depth 2), but the ruleset.xml in the frenck/php-compatibility is in level 1 within the install path, the path is never added to the config.

Since I’m already kinda tired and I don’t know if this is really just a “greater than vs greater than equals” issue or if I’m missing something in the big picture, I was kinda too lazy to fork, write a test and create a pull request. 😉

If I change the depth to >0, it worked for a clean install and for the update.

Maybe @christopher-hopper sees instantly if the >1 is acutally needed or if >0 is sufficent enough?