PHPCSStandards / composer-installer

Composer installer for PHP_CodeSniffer coding standards
https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer
MIT License
549 stars 36 forks source link

Question: how does this library handle multiple standards as dependencies ? #24

Closed jrfnl closed 7 years ago

jrfnl commented 7 years ago

Question

Say you have a project in which you require both a project specific coding standard, such as the Joomla or WordPress Coding Standards, as well as the PHPCompatibility standard to check for cross-version compatibility issues.

Assume that both these PHPCS standards require this library and have their type set to phpcodesniffer-standard,

How does this installer handle that ?

PHPCS by default overwrites a previously registered installed_path when the command is run again.

Does this library collect all the paths and run the command once at the end ? Or would each subsequent CS dependency overwrite the path like PHPCS does ?

Related: https://github.com/squizlabs/PHP_CodeSniffer/issues/1436

Potherca commented 7 years ago

Given the scenario that a user has defined two sniffs as a dependency, the installer installs both sniffs.

The path of both sniffs are added to the PHP Codesniffer configuration file at vendor/squizlabs/php_codesniffer/CodeSniffer.conf.

A full working example, including a more verbose explanation can be found at https://github.com/Potherca/phpcodesniffer-composer-installer_issue-24

If anything is unclear or information is missing, don't hesitate to ask.

jrfnl commented 7 years ago

@Potherca Thanks for the clarification. One more question: what about if the user installs the sniff library as "global" using Composer and they already have one or more other standards installed globally ? (which they're not updating at the same time)

Potherca commented 7 years ago

The behaviour between "global" or "local" install is the same.

If a sniff is already installed before the installer is installed, the installer does not do anything when it is installed (as the sniff is already installed and no installation is needed).

However, when another sniff is installed after the installer has been installed, both sniffs will be installed by the installer.

I have updated and expanded the working example to including these scenario's (both the incremental scenario and the global scenario).

jrfnl commented 7 years ago

@Potherca Thanks for the clarification. This has answered my questions.