v2.2.0
This commit is contained in:
parent
a6b592a27d
commit
ed5c696fbe
4 changed files with 8655 additions and 946 deletions
601
vendor/dealerdirect/phpcodesniffer-composer-installer/CHANGELOG.md
vendored
Normal file
601
vendor/dealerdirect/phpcodesniffer-composer-installer/CHANGELOG.md
vendored
Normal file
|
|
@ -0,0 +1,601 @@
|
|||
# Change Log for the Composer Installer for PHP CodeSniffer
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
This projects adheres to [Keep a CHANGELOG](https://keepachangelog.com/) and uses [Semantic Versioning](https://semver.org/).
|
||||
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
_Nothing yet._
|
||||
|
||||
|
||||
## [v1.2.1] - 2026-05-06
|
||||
|
||||
### Changed
|
||||
- Various housekeeping, including improvements to CI.
|
||||
|
||||
### Fixed
|
||||
- Fix potential error when running `composer install` with an `open_basedir` restriction in effect. Thanks [@srebb] ! [#271], [#272]
|
||||
|
||||
[#271]: https://github.com/PHPCSStandards/composer-installer/issues/271
|
||||
[#272]: https://github.com/PHPCSStandards/composer-installer/pull/272
|
||||
|
||||
|
||||
## [v1.2.0] - 2025-11-11
|
||||
|
||||
### Changed
|
||||
- Various housekeeping, including improvements to the documentation and tests.
|
||||
|
||||
### Removed
|
||||
- Drop support for PHP_CodeSniffer 2.x. Thanks [@jrfnl] ! [#261]
|
||||
|
||||
[#261]: https://github.com/PHPCSStandards/composer-installer/pull/261
|
||||
|
||||
|
||||
## [v1.1.2] - 2025-07-17
|
||||
|
||||
### Changed
|
||||
- General housekeeping.
|
||||
|
||||
### Fixed
|
||||
- [#247]: Potential fatal error when the Composer EventDispatcher is called programmatically from an integration. Thanks [@jrfnl] ! [#248]
|
||||
|
||||
[#247]: https://github.com/PHPCSStandards/composer-installer/issues/247
|
||||
[#248]: https://github.com/PHPCSStandards/composer-installer/pull/248
|
||||
|
||||
|
||||
## [v1.1.1] - 2025-06-27
|
||||
|
||||
### Changed
|
||||
- Various housekeeping, including improvements to the documentation.
|
||||
|
||||
### Fixed
|
||||
- [#239]: The PHP_CodeSniffer package could not be always found when running the plugin in a Drupal or Magento setup. Thanks [@jrfnl] ! [#245]
|
||||
|
||||
[#239]: https://github.com/PHPCSStandards/composer-installer/issues/239
|
||||
[#245]: https://github.com/PHPCSStandards/composer-installer/pull/245
|
||||
|
||||
|
||||
## [v1.1.0] - 2025-06-24
|
||||
|
||||
### Changed
|
||||
- Various housekeeping, including improvements to the documentation and tests. Thanks [@SplotyCode], [@fredden] for contributing!
|
||||
|
||||
### Removed
|
||||
- Drop support for Composer v1.x. Thanks [@fredden] ! [#230]
|
||||
|
||||
[#230]: https://github.com/PHPCSStandards/composer-installer/pull/230
|
||||
|
||||
|
||||
## [v1.0.0] - 2023-01-05
|
||||
|
||||
### Breaking changes
|
||||
- Rename namespace prefix from Dealerdirect to PHPCSStandards by [@jrfnl] in [#191]
|
||||
- Drop support for PHP 5.3 by [@jrfnl] in [#147]
|
||||
|
||||
### Changed
|
||||
- Correct grammar in error message by [@fredden] in [#189]
|
||||
- .gitattributes: sync with current repo state by [@jrfnl] in [#198]
|
||||
- PHPCSVersions: update URL references by [@jrfnl] in [#161]
|
||||
- README: remove references to Scrutinizer by [@jrfnl] in [#157]
|
||||
- Rename references to master branch by [@Potherca] in [#201]
|
||||
- Update repo references by [@jrfnl] in [#158]
|
||||
- GH Actions: add builds against Composer 2.2 for PHP 7.2 - 8.x by [@jrfnl] in [#172]
|
||||
- GH Actions: bust the cache semi-regularly by [@jrfnl] in [#192]
|
||||
- GH Actions: fix builds on Windows with PHP 8.2 by [@jrfnl] in [#180]
|
||||
- GH Actions: fix up fail-fast for setup-php by [@jrfnl] in [#195]
|
||||
- GH Actions: run integration tests against Composer snapshot by [@jrfnl] in [#163]
|
||||
- GH Actions: run linting against against ubuntu-latest by [@jrfnl] in [#184]
|
||||
- GH Actions/Securitycheck: update the security checker download by [@jrfnl] in [#178]
|
||||
- GH Actions/Securitycheck: update the security checker download by [@jrfnl] in [#186]
|
||||
- GH Actions/Securitycheck: update the security checker download by [@jrfnl] in [#190]
|
||||
- GH Actions: selectively use fail-fast with setup-php by [@jrfnl] in [#194]
|
||||
- GH Actions: stop running tests against PHP 5.5/Composer 1.x on Windows (and remove work-arounds) by [@jrfnl] in [#183]
|
||||
- GH Actions: various tweaks / PHP 8.2 not allowed to fail by [@jrfnl] in [#193]
|
||||
- GH Actions: version update for various predefined actions by [@jrfnl] in [#170]
|
||||
- Update YamLint by [@Potherca] in [#173]
|
||||
- Add initial integration test setup and first few tests by [@jrfnl] in [#153]
|
||||
- BaseLineTest: stabilize the message checks by [@jrfnl] in [#162]
|
||||
- PlayNiceWithScriptsTest: wrap output expectation in condition by [@jrfnl] in [#179]
|
||||
- RegisterExternalStandardsTest: add new tests by [@jrfnl] in [#165]
|
||||
- RegisterExternalStandardsTest: stabilize test for Composer v1 on Windows with PHP 5.5 by [@jrfnl] in [#171]
|
||||
- TestCase::executeCliCommand(): retry Composer commands on a particular exception by [@jrfnl] in [#164]
|
||||
- Tests: add new InstalledPathsOrderTest by [@jrfnl] in [#176]
|
||||
- Tests: add new InstallUpdateEventsTest and NonInstallUpdateEventsTest by [@jrfnl] in [#174]
|
||||
- Tests: add new InvalidPackagesTest by [@jrfnl] in [#168]
|
||||
- Tests: add new PlayNiceWithScriptsTest by [@jrfnl] in [#169]
|
||||
- Tests: add new PreexistingPHPCSConfigTest by [@jrfnl] in [#166]
|
||||
- Tests: add new PreexistingPHPCSInstalledPathsConfigTest + bug fix by [@jrfnl] in [#167]
|
||||
- Tests: add new RemovePluginTest by [@jrfnl] in [#177]
|
||||
- Tests: add new RootPackageHandlingTest + bugfix by [@jrfnl] in [#175]
|
||||
|
||||
### Fixed
|
||||
- Plugin: improve feedback by [@jrfnl] in [#182]
|
||||
|
||||
[#147]: https://github.com/PHPCSStandards/composer-installer/pull/147
|
||||
[#153]: https://github.com/PHPCSStandards/composer-installer/pull/153
|
||||
[#157]: https://github.com/PHPCSStandards/composer-installer/pull/157
|
||||
[#158]: https://github.com/PHPCSStandards/composer-installer/pull/158
|
||||
[#161]: https://github.com/PHPCSStandards/composer-installer/pull/161
|
||||
[#162]: https://github.com/PHPCSStandards/composer-installer/pull/162
|
||||
[#163]: https://github.com/PHPCSStandards/composer-installer/pull/163
|
||||
[#164]: https://github.com/PHPCSStandards/composer-installer/pull/164
|
||||
[#165]: https://github.com/PHPCSStandards/composer-installer/pull/165
|
||||
[#166]: https://github.com/PHPCSStandards/composer-installer/pull/166
|
||||
[#167]: https://github.com/PHPCSStandards/composer-installer/pull/167
|
||||
[#168]: https://github.com/PHPCSStandards/composer-installer/pull/168
|
||||
[#169]: https://github.com/PHPCSStandards/composer-installer/pull/169
|
||||
[#170]: https://github.com/PHPCSStandards/composer-installer/pull/170
|
||||
[#171]: https://github.com/PHPCSStandards/composer-installer/pull/171
|
||||
[#172]: https://github.com/PHPCSStandards/composer-installer/pull/172
|
||||
[#173]: https://github.com/PHPCSStandards/composer-installer/pull/173
|
||||
[#174]: https://github.com/PHPCSStandards/composer-installer/pull/174
|
||||
[#175]: https://github.com/PHPCSStandards/composer-installer/pull/175
|
||||
[#176]: https://github.com/PHPCSStandards/composer-installer/pull/176
|
||||
[#177]: https://github.com/PHPCSStandards/composer-installer/pull/177
|
||||
[#178]: https://github.com/PHPCSStandards/composer-installer/pull/178
|
||||
[#179]: https://github.com/PHPCSStandards/composer-installer/pull/179
|
||||
[#180]: https://github.com/PHPCSStandards/composer-installer/pull/180
|
||||
[#182]: https://github.com/PHPCSStandards/composer-installer/pull/182
|
||||
[#183]: https://github.com/PHPCSStandards/composer-installer/pull/183
|
||||
[#184]: https://github.com/PHPCSStandards/composer-installer/pull/184
|
||||
[#186]: https://github.com/PHPCSStandards/composer-installer/pull/186
|
||||
[#189]: https://github.com/PHPCSStandards/composer-installer/pull/189
|
||||
[#190]: https://github.com/PHPCSStandards/composer-installer/pull/190
|
||||
[#191]: https://github.com/PHPCSStandards/composer-installer/pull/191
|
||||
[#192]: https://github.com/PHPCSStandards/composer-installer/pull/192
|
||||
[#193]: https://github.com/PHPCSStandards/composer-installer/pull/193
|
||||
[#194]: https://github.com/PHPCSStandards/composer-installer/pull/194
|
||||
[#195]: https://github.com/PHPCSStandards/composer-installer/pull/195
|
||||
[#198]: https://github.com/PHPCSStandards/composer-installer/pull/198
|
||||
[#201]: https://github.com/PHPCSStandards/composer-installer/pull/201
|
||||
|
||||
|
||||
## [v0.7.2] - 2022-02-04
|
||||
|
||||
### Changed
|
||||
- Add details regarding QA automation in CONTRIBUTING.md file. by [@Potherca] in [#133]
|
||||
- Add mention of Composer and PHP compatibility to project README. by [@Potherca] in [#132]
|
||||
- Composer: tweak PHPCS version constraint by [@jrfnl] in [#152]
|
||||
- CONTRIBUTING: remove duplicate code of conduct by [@jrfnl] in [#148]
|
||||
- Document release process by [@Potherca] in [#118]
|
||||
- Plugin::loadInstalledPaths(): config-show always shows all by [@jrfnl] in [#154]
|
||||
- README: minor tweaks by [@jrfnl] in [#149]
|
||||
- README: update with information about Composer >= 2.2 by [@jrfnl] in [#141]
|
||||
- Replace deprecated Sensiolabs security checker by [@paras-malhotra] in [#130]
|
||||
- Stabilize a condition by [@jrfnl] in [#127]
|
||||
- Update copyright year by [@jrfnl] in [#138]
|
||||
- Various minor tweaks by [@jrfnl] in [#151]
|
||||
- Change YamlLint config to prevent "truthy" warning. by [@Potherca] in [#144]
|
||||
- GH Actions: PHP 8.1 has been released by [@jrfnl] in [#139]
|
||||
- Travis: line length tweaks by [@jrfnl] in [#128]
|
||||
- CI: Switch to GH Actions by [@jrfnl] in [#137]
|
||||
- CI: various updates by [@jrfnl] in [#140]
|
||||
|
||||
[#118]: https://github.com/PHPCSStandards/composer-installer/pull/118
|
||||
[#127]: https://github.com/PHPCSStandards/composer-installer/pull/127
|
||||
[#128]: https://github.com/PHPCSStandards/composer-installer/pull/128
|
||||
[#130]: https://github.com/PHPCSStandards/composer-installer/pull/130
|
||||
[#132]: https://github.com/PHPCSStandards/composer-installer/pull/132
|
||||
[#133]: https://github.com/PHPCSStandards/composer-installer/pull/133
|
||||
[#137]: https://github.com/PHPCSStandards/composer-installer/pull/137
|
||||
[#138]: https://github.com/PHPCSStandards/composer-installer/pull/138
|
||||
[#139]: https://github.com/PHPCSStandards/composer-installer/pull/139
|
||||
[#140]: https://github.com/PHPCSStandards/composer-installer/pull/140
|
||||
[#141]: https://github.com/PHPCSStandards/composer-installer/pull/141
|
||||
[#144]: https://github.com/PHPCSStandards/composer-installer/pull/144
|
||||
[#148]: https://github.com/PHPCSStandards/composer-installer/pull/148
|
||||
[#149]: https://github.com/PHPCSStandards/composer-installer/pull/149
|
||||
[#151]: https://github.com/PHPCSStandards/composer-installer/pull/151
|
||||
[#152]: https://github.com/PHPCSStandards/composer-installer/pull/152
|
||||
[#154]: https://github.com/PHPCSStandards/composer-installer/pull/154
|
||||
|
||||
|
||||
## [v0.7.1] - 2020-12-07
|
||||
|
||||
### Closed issues
|
||||
- Order of installed_paths inconsistent between runs [#125]
|
||||
- Maintaining this project and Admin rights [#113]
|
||||
|
||||
### Changed
|
||||
- Sort list of installed paths before saving for consistency by [@kevinfodness] in [#126]
|
||||
- Update code of conduct by [@Potherca] in [#117]
|
||||
- Add remark configuration by [@Potherca] in [#122]
|
||||
- Travis: add build against PHP 8.0 by [@jrfnl] in [#124]
|
||||
|
||||
### Fixed
|
||||
- Fixed v4 constraint by [@GrahamCampbell] in [#115]
|
||||
|
||||
[#113]: https://github.com/PHPCSStandards/composer-installer/issues/113
|
||||
[#115]: https://github.com/PHPCSStandards/composer-installer/pull/115
|
||||
[#117]: https://github.com/PHPCSStandards/composer-installer/pull/117
|
||||
[#122]: https://github.com/PHPCSStandards/composer-installer/pull/122
|
||||
[#124]: https://github.com/PHPCSStandards/composer-installer/pull/124
|
||||
[#125]: https://github.com/PHPCSStandards/composer-installer/issues/125
|
||||
[#126]: https://github.com/PHPCSStandards/composer-installer/pull/126
|
||||
|
||||
|
||||
## [v0.7.0] - 2020-06-25
|
||||
|
||||
### Closed issues
|
||||
- Composer 2.x compatibility [#108]
|
||||
- Add link to Packagist on main page [#110]
|
||||
- Switch from Travis CI .org to .com [#112]
|
||||
|
||||
### Added
|
||||
- Allow installation on PHP 8 by [@jrfnl] in [#106]
|
||||
- Support Composer 2.0 by [@jrfnl] in [#111]
|
||||
|
||||
### Changed
|
||||
- Test with PHPCS 4.x and allow installation when using PHPCS 4.x by [@jrfnl] in [#107]
|
||||
- Fix case of class name by [@Seldaek] in [#109]
|
||||
|
||||
[#106]: https://github.com/PHPCSStandards/composer-installer/pull/106
|
||||
[#107]: https://github.com/PHPCSStandards/composer-installer/pull/107
|
||||
[#108]: https://github.com/PHPCSStandards/composer-installer/issues/108
|
||||
[#109]: https://github.com/PHPCSStandards/composer-installer/pull/109
|
||||
[#110]: https://github.com/PHPCSStandards/composer-installer/issues/110
|
||||
[#111]: https://github.com/PHPCSStandards/composer-installer/pull/111
|
||||
[#112]: https://github.com/PHPCSStandards/composer-installer/issues/112
|
||||
|
||||
|
||||
## [v0.6.2] - 2020-01-29
|
||||
|
||||
### Fixed
|
||||
- Composer scripts/commands broken in 0.6.0 update by [@BrianHenryIE] in [#105]
|
||||
|
||||
[#105]: https://github.com/PHPCSStandards/composer-installer/pull/105
|
||||
|
||||
## [v0.6.1] - 2020-01-27
|
||||
|
||||
### Closed issues
|
||||
- Do not exit with code 1 on uninstall (--no-dev) [#103]
|
||||
|
||||
### Changed
|
||||
- Readme: minor tweak now 0.6.0 has been released [#102] ([@jrfnl])
|
||||
|
||||
### Fixed
|
||||
- [#103]: Fix for issue #103 [#104] ([@Potherca])
|
||||
|
||||
[#102]: https://github.com/PHPCSStandards/composer-installer/pull/102
|
||||
[#103]: https://github.com/PHPCSStandards/composer-installer/issues/103
|
||||
[#104]: https://github.com/PHPCSStandards/composer-installer/pull/104
|
||||
|
||||
|
||||
## [v0.6.0] - 2020-01-19
|
||||
|
||||
### Closed issues
|
||||
- Composer PHP version appears not to be respected [#79]
|
||||
- Allow a string value for extra.phpcodesniffer-search-depth [#82]
|
||||
- Add [@jrfnl] as (co)maintainer to this project [#87]
|
||||
|
||||
### Added
|
||||
- Add support for a string phpcodesniffer-search-depth config value set via composer config by [@TravisCarden] in [#85]
|
||||
- Send an exit code when the script terminates by [@jrfnl] in [#93]
|
||||
- Verify the installed_paths after save by [@jrfnl] in [#97]
|
||||
|
||||
### Changed
|
||||
- CS: fix compliance with PSR12 by [@jrfnl] in [#88]
|
||||
- Improve GH issue template by [@jrfnl] in [#94]
|
||||
- Readme: add section about including this plugin from an external PHPCS standard by [@jrfnl] in [#95]
|
||||
- Bug report template: further enhancement by [@jrfnl] in [#99]
|
||||
- Update copyright year. by [@Potherca] in [#101]
|
||||
- Adding linting jobs in github action by [@mjrider] in [#96]
|
||||
- GH Actions: minor tweaks: by [@jrfnl] in [#100]
|
||||
- Travis: disable Xdebug by [@jrfnl] in [#89]
|
||||
- Travis: test against PHP 7.4, not snapshot by [@jrfnl] in [#90]
|
||||
- Travis: use a mix of PHPCS versions in the matrix by [@jrfnl] in [#91]
|
||||
- Update Travis file and fix build by [@Potherca] in [#86]
|
||||
|
||||
### Fixed
|
||||
- [#79]: Respect PHP version used by Composer and provide better feedback on failure by [@jrfnl] in [#80]
|
||||
- Bug fix: loadInstalledPaths() very very broken since PHPCS 3.1.0 by [@jrfnl] in [#98]
|
||||
|
||||
[#79]: https://github.com/PHPCSStandards/composer-installer/issues/79
|
||||
[#80]: https://github.com/PHPCSStandards/composer-installer/issues/80
|
||||
[#82]: https://github.com/PHPCSStandards/composer-installer/issues/82
|
||||
[#85]: https://github.com/PHPCSStandards/composer-installer/pull/85
|
||||
[#86]: https://github.com/PHPCSStandards/composer-installer/pull/86
|
||||
[#87]: https://github.com/PHPCSStandards/composer-installer/issues/87
|
||||
[#88]: https://github.com/PHPCSStandards/composer-installer/pull/88
|
||||
[#89]: https://github.com/PHPCSStandards/composer-installer/pull/89
|
||||
[#90]: https://github.com/PHPCSStandards/composer-installer/pull/90
|
||||
[#91]: https://github.com/PHPCSStandards/composer-installer/pull/91
|
||||
[#93]: https://github.com/PHPCSStandards/composer-installer/pull/93
|
||||
[#94]: https://github.com/PHPCSStandards/composer-installer/pull/94
|
||||
[#95]: https://github.com/PHPCSStandards/composer-installer/pull/95
|
||||
[#96]: https://github.com/PHPCSStandards/composer-installer/pull/96
|
||||
[#97]: https://github.com/PHPCSStandards/composer-installer/pull/97
|
||||
[#98]: https://github.com/PHPCSStandards/composer-installer/issues/98
|
||||
[#99]: https://github.com/PHPCSStandards/composer-installer/pull/99
|
||||
[#100]: https://github.com/PHPCSStandards/composer-installer/pull/100
|
||||
[#101]: https://github.com/PHPCSStandards/composer-installer/pull/101
|
||||
|
||||
|
||||
## [v0.5.0] - 2018-10-26
|
||||
|
||||
### Closed issues
|
||||
- Scan depth as parameter [#45]
|
||||
- phpcs: Exit Code: 127 (Command not found) on every Composer command [#48]
|
||||
- The composer plugin implementation seems to be breaking the composer lifecycle [#49]
|
||||
- Installation error [#53]
|
||||
- Broke composer commands when used with wp-cli/package-command [#59]
|
||||
- Getting a new stable release [#60]
|
||||
- Support PHP CodeSniffer standards in packages installed outside of the vendor directory [#63]
|
||||
|
||||
### Added
|
||||
- Adds the ability to set the max depth from the composer.json file by [@Potherca] in [#46]
|
||||
|
||||
### Changed
|
||||
- Build/PHPCS: update PHPCompatibility repo name by [@jrfnl] in [#54]
|
||||
- README: remove VersionEye badge by [@jrfnl] in [#55]
|
||||
- README: replace maintenance badge by [@jrfnl] in [#56]
|
||||
- Execute phpcs and security-checker from vendor/bin by [@gapple] in [#52]
|
||||
- PHPCS: various minor tweaks by [@jrfnl] in [#57]
|
||||
- Travis: various tweaks by [@jrfnl] in [#58]
|
||||
- Use PHPCompatibility 9.0.0 by [@jrfnl] in [#61]
|
||||
- Build/Travis: test builds against PHP 7.3 by [@jrfnl] in [#62]
|
||||
- Updates copyright year by [@frenck] in [#67]
|
||||
- Enforces PSR12 by [@frenck] in [#66]
|
||||
- Updates contact information by [@frenck] in [#68]
|
||||
- Updates README, spelling/grammar, removed Working section by [@frenck] in [#69]
|
||||
- Replaces ProcessBuilder by ProcessExecutor by [@frenck] in [#70]
|
||||
- Refactors relative path logic by [@frenck] in [#71]
|
||||
- Removes suggested packages by [@frenck] in [#72]
|
||||
- Ensures absolute paths during detection phase by [@frenck] in [#73]
|
||||
- Trivial code cleanup by [@frenck] in [#74]
|
||||
- Fixes duplicate declaration of cwd by [@frenck] in [#75]
|
||||
- Removes HHVM from TravisCI by [@frenck] in [#76]
|
||||
- Adds PHP_CodeSniffer version constraints by [@frenck] in [#77]
|
||||
|
||||
### Fixed
|
||||
- [#49]: Move loadInstalledPaths from init to onDependenciesChangedEvent by [@gapple] in [#51]
|
||||
|
||||
[#45]: https://github.com/PHPCSStandards/composer-installer/issues/45
|
||||
[#46]: https://github.com/PHPCSStandards/composer-installer/pull/46
|
||||
[#48]: https://github.com/PHPCSStandards/composer-installer/issues/48
|
||||
[#49]: https://github.com/PHPCSStandards/composer-installer/issues/49
|
||||
[#51]: https://github.com/PHPCSStandards/composer-installer/pull/51
|
||||
[#52]: https://github.com/PHPCSStandards/composer-installer/pull/52
|
||||
[#53]: https://github.com/PHPCSStandards/composer-installer/issues/53
|
||||
[#54]: https://github.com/PHPCSStandards/composer-installer/pull/54
|
||||
[#55]: https://github.com/PHPCSStandards/composer-installer/pull/55
|
||||
[#56]: https://github.com/PHPCSStandards/composer-installer/pull/56
|
||||
[#57]: https://github.com/PHPCSStandards/composer-installer/pull/57
|
||||
[#58]: https://github.com/PHPCSStandards/composer-installer/pull/58
|
||||
[#59]: https://github.com/PHPCSStandards/composer-installer/issues/59
|
||||
[#60]: https://github.com/PHPCSStandards/composer-installer/issues/60
|
||||
[#61]: https://github.com/PHPCSStandards/composer-installer/pull/61
|
||||
[#62]: https://github.com/PHPCSStandards/composer-installer/pull/62
|
||||
[#63]: https://github.com/PHPCSStandards/composer-installer/issues/63
|
||||
[#66]: https://github.com/PHPCSStandards/composer-installer/pull/66
|
||||
[#67]: https://github.com/PHPCSStandards/composer-installer/pull/67
|
||||
[#68]: https://github.com/PHPCSStandards/composer-installer/pull/68
|
||||
[#69]: https://github.com/PHPCSStandards/composer-installer/pull/69
|
||||
[#70]: https://github.com/PHPCSStandards/composer-installer/pull/70
|
||||
[#71]: https://github.com/PHPCSStandards/composer-installer/pull/71
|
||||
[#72]: https://github.com/PHPCSStandards/composer-installer/pull/72
|
||||
[#73]: https://github.com/PHPCSStandards/composer-installer/pull/73
|
||||
[#74]: https://github.com/PHPCSStandards/composer-installer/pull/74
|
||||
[#75]: https://github.com/PHPCSStandards/composer-installer/pull/75
|
||||
[#76]: https://github.com/PHPCSStandards/composer-installer/pull/76
|
||||
[#77]: https://github.com/PHPCSStandards/composer-installer/pull/77
|
||||
|
||||
|
||||
## [v0.4.4] - 2017-12-06
|
||||
|
||||
### Closed issues
|
||||
- PHP 7.2 compatibility issue [#43]
|
||||
|
||||
### Changed
|
||||
- Update Travis CI svg badge and link URLs [#42] ([@ntwb])
|
||||
- Add PHP 7.2 to Travis CI [#41] ([@ntwb])
|
||||
- Docs: Fix link to releases [#40] ([@GaryJones])
|
||||
|
||||
[#40]: https://github.com/PHPCSStandards/composer-installer/pull/40
|
||||
[#41]: https://github.com/PHPCSStandards/composer-installer/pull/41
|
||||
[#42]: https://github.com/PHPCSStandards/composer-installer/pull/42
|
||||
[#43]: https://github.com/PHPCSStandards/composer-installer/issues/43
|
||||
|
||||
|
||||
## [v0.4.3] - 2017-09-18
|
||||
|
||||
### Changed
|
||||
- CS: Add PHP 5.3 compatibility [#39] ([@GaryJones])
|
||||
- Local PHPCS [#38] ([@GaryJones])
|
||||
|
||||
[#38]: https://github.com/PHPCSStandards/composer-installer/pull/38
|
||||
[#39]: https://github.com/PHPCSStandards/composer-installer/pull/39
|
||||
|
||||
|
||||
## [v0.4.2] - 2017-08-16
|
||||
|
||||
### Changed
|
||||
- Docs: Rename example script [#35] ([@GaryJones])
|
||||
- Update README.md [#36] ([@jrfnl])
|
||||
- Documentation update. [#37] ([@frenck])
|
||||
|
||||
[#35]: https://github.com/PHPCSStandards/composer-installer/pull/35
|
||||
[#36]: https://github.com/PHPCSStandards/composer-installer/pull/36
|
||||
[#37]: https://github.com/PHPCSStandards/composer-installer/pull/37
|
||||
|
||||
|
||||
## [v0.4.1] - 2017-08-01
|
||||
|
||||
### Closed issues
|
||||
- Incorrect relative paths for WPCS [#33]
|
||||
|
||||
### Fixed
|
||||
- [#33]: Changes the way the installed_paths are set. [#34] ([@frenck])
|
||||
|
||||
[#33]: https://github.com/PHPCSStandards/composer-installer/issues/33
|
||||
[#34]: https://github.com/PHPCSStandards/composer-installer/pull/34
|
||||
|
||||
|
||||
## [v0.4.0] - 2017-05-11
|
||||
|
||||
### Closed issues
|
||||
- Add support for code standards in root of repository for PHP_CodeSniffer 3.x [#26]
|
||||
- Config codings styles in composer.json from project [#23]
|
||||
- Check the root package for sniffs to install [#20]
|
||||
- Document the ability to execute the main plugin functionality directly [#18]
|
||||
- Add a CHANGELOG.md [#17]
|
||||
- Install sniffs with relative paths in CodeSniffer.conf [#14]
|
||||
|
||||
### Added
|
||||
- Support for coding standard in the root repository for PHP_CodeSniffer v3.x [#30] ([@frenck])
|
||||
- Added support for having coding standards in the root package [#25] ([@frenck])
|
||||
|
||||
### Changed
|
||||
- Local projects uses relative paths to their coding standards [#28] ([@frenck])
|
||||
- Docs: Updated README. [#31] ([@frenck])
|
||||
- Docs: Adds reference to calling the script directly in the README. [#29] ([@Potherca])
|
||||
- Adds Travis-CI configuration file. [#27] ([@Potherca])
|
||||
|
||||
|
||||
[#14]: https://github.com/PHPCSStandards/composer-installer/issues/14
|
||||
[#17]: https://github.com/PHPCSStandards/composer-installer/issues/17
|
||||
[#18]: https://github.com/PHPCSStandards/composer-installer/issues/18
|
||||
[#20]: https://github.com/PHPCSStandards/composer-installer/issues/20
|
||||
[#23]: https://github.com/PHPCSStandards/composer-installer/issues/23
|
||||
[#25]: https://github.com/PHPCSStandards/composer-installer/pull/25
|
||||
[#26]: https://github.com/PHPCSStandards/composer-installer/issues/26
|
||||
[#27]: https://github.com/PHPCSStandards/composer-installer/pull/27
|
||||
[#28]: https://github.com/PHPCSStandards/composer-installer/pull/28
|
||||
[#29]: https://github.com/PHPCSStandards/composer-installer/pull/29
|
||||
[#31]: https://github.com/PHPCSStandards/composer-installer/pull/31
|
||||
|
||||
|
||||
## [v0.3.2] - 2017-03-29
|
||||
|
||||
### Closed issues
|
||||
- Coding Standard tries itself to install with installPath when it's the root package [#19]
|
||||
|
||||
### Changed
|
||||
- Improvements to the documentation [#22] ([@Potherca])
|
||||
- Added instanceof check to prevent root package from being installed [#21] ([@bastianschwarz])
|
||||
|
||||
### Fixed
|
||||
- [#13]: Incorrect coding standards search depth [#15] ([@frenck])
|
||||
|
||||
[#19]: https://github.com/PHPCSStandards/composer-installer/issues/19
|
||||
[#21]: https://github.com/PHPCSStandards/composer-installer/pull/21
|
||||
[#22]: https://github.com/PHPCSStandards/composer-installer/pull/22
|
||||
|
||||
|
||||
## [v0.3.1] - 2017-02-17
|
||||
|
||||
### Closed issues
|
||||
- Plugin not working correctly when sniffs install depth is equal to "1" [#13]
|
||||
- Create new stable release version to support wider use [#11]
|
||||
|
||||
### Fixed
|
||||
- [#13]: Incorrect coding standards search depth [#15] ([@frenck])
|
||||
|
||||
[#11]: https://github.com/PHPCSStandards/composer-installer/issues/11
|
||||
[#13]: https://github.com/PHPCSStandards/composer-installer/issues/13
|
||||
[#15]: https://github.com/PHPCSStandards/composer-installer/pull/15
|
||||
|
||||
|
||||
## [v0.3.0] - 2017-02-15
|
||||
|
||||
### Implemented enhancements
|
||||
- Install Plugin provides no feedback [#7]
|
||||
- Installing coding standards when executing Composer with --no-scripts [#4]
|
||||
- Github contribution templates [#10] ([@christopher-hopper])
|
||||
- Show config actions and a result as Console output [#8] ([@christopher-hopper])
|
||||
- Adds static function to call the Plugin::onDependenciesChangedEvent() method [#5] ([@Potherca])
|
||||
|
||||
### Added
|
||||
- Support existing standards packages with subfolders [#6] ([@christopher-hopper])
|
||||
|
||||
### Changed
|
||||
- Improved documentation [#12] ([@frenck])
|
||||
- Removal of lgtm.co [#3] ([@frenck])
|
||||
|
||||
[#3]: https://github.com/PHPCSStandards/composer-installer/pull/3
|
||||
[#4]: https://github.com/PHPCSStandards/composer-installer/issues/4
|
||||
[#5]: https://github.com/PHPCSStandards/composer-installer/pull/5
|
||||
[#6]: https://github.com/PHPCSStandards/composer-installer/pull/6
|
||||
[#7]: https://github.com/PHPCSStandards/composer-installer/issues/7
|
||||
[#8]: https://github.com/PHPCSStandards/composer-installer/pull/8
|
||||
[#10]: https://github.com/PHPCSStandards/composer-installer/pull/10
|
||||
[#12]: https://github.com/PHPCSStandards/composer-installer/pull/12
|
||||
|
||||
|
||||
## [v0.2.1] - 2016-11-01
|
||||
|
||||
Fixes an issue with having this plugin installed globally within composer, but using your global composer installation on a local repository without PHP_CodeSniffer installed.
|
||||
|
||||
### Fixed
|
||||
- Bugfix: Plugin fails when PHP_CodeSniffer is not installed [#2] ([@frenck])
|
||||
|
||||
[#2]: https://github.com/PHPCSStandards/composer-installer/pull/2
|
||||
|
||||
|
||||
## [v0.2.0] - 2016-11-01
|
||||
|
||||
For this version on, this installer no longer messes with the installation paths of composer libraries, but instead, it configures PHP_CodeSniffer to look into other directories for coding standards.
|
||||
|
||||
### Changed
|
||||
- PHPCS Configuration management [#1] ([@frenck])
|
||||
|
||||
[#1]: https://github.com/PHPCSStandards/composer-installer/pull/1
|
||||
|
||||
|
||||
## [v0.1.1] - 2016-10-24
|
||||
|
||||
### Changed
|
||||
- Standard name mapping improvements
|
||||
|
||||
|
||||
## v0.1.0 - 2016-10-23
|
||||
|
||||
First useable release.
|
||||
|
||||
[v1.2.1]: https://github.com/PHPCSStandards/composer-installer/compare/v1.2.0...v1.2.1
|
||||
[v1.2.0]: https://github.com/PHPCSStandards/composer-installer/compare/v1.1.2...v1.2.0
|
||||
[v1.1.2]: https://github.com/PHPCSStandards/composer-installer/compare/v1.1.1...v1.1.2
|
||||
[v1.1.1]: https://github.com/PHPCSStandards/composer-installer/compare/v1.1.0...v1.1.1
|
||||
[v1.1.0]: https://github.com/PHPCSStandards/composer-installer/compare/v1.0.0...v1.1.0
|
||||
[v1.0.0]: https://github.com/PHPCSStandards/composer-installer/compare/v0.7.2...v1.0.0
|
||||
[v0.7.2]: https://github.com/PHPCSStandards/composer-installer/compare/v0.7.1...v0.7.2
|
||||
[v0.7.1]: https://github.com/PHPCSStandards/composer-installer/compare/v0.7.0...v0.7.1
|
||||
[v0.7.0]: https://github.com/PHPCSStandards/composer-installer/compare/v0.6.2...v0.7.0
|
||||
[v0.6.2]: https://github.com/PHPCSStandards/composer-installer/compare/v0.6.1...v0.6.2
|
||||
[v0.6.1]: https://github.com/PHPCSStandards/composer-installer/compare/v0.6.0...v0.6.1
|
||||
[v0.6.0]: https://github.com/PHPCSStandards/composer-installer/compare/v0.5.0...v0.6.0
|
||||
[v0.5.0]: https://github.com/PHPCSStandards/composer-installer/compare/v0.4.4...v0.5.0
|
||||
[v0.4.4]: https://github.com/PHPCSStandards/composer-installer/compare/v0.4.3...v0.4.4
|
||||
[v0.4.3]: https://github.com/PHPCSStandards/composer-installer/compare/v0.4.2...v0.4.3
|
||||
[v0.4.2]: https://github.com/PHPCSStandards/composer-installer/compare/v0.4.1...v0.4.2
|
||||
[v0.4.1]: https://github.com/PHPCSStandards/composer-installer/compare/v0.4.0...v0.4.1
|
||||
[v0.4.0]: https://github.com/PHPCSStandards/composer-installer/compare/v0.3.2...v0.4.0
|
||||
[v0.3.2]: https://github.com/PHPCSStandards/composer-installer/compare/v0.3.1...v0.3.2
|
||||
[v0.3.1]: https://github.com/PHPCSStandards/composer-installer/compare/v0.3.0...v0.3.1
|
||||
[v0.3.0]: https://github.com/PHPCSStandards/composer-installer/compare/v0.2.1...v0.3.0
|
||||
[v0.2.1]: https://github.com/PHPCSStandards/composer-installer/compare/v0.2.0...v0.2.1
|
||||
[v0.2.0]: https://github.com/PHPCSStandards/composer-installer/compare/v0.1.1...v0.2.0
|
||||
[v0.1.1]: https://github.com/PHPCSStandards/composer-installer/compare/v0.1.0...v0.1.1
|
||||
|
||||
[PHP_CodeSniffer]: https://github.com/PHPCSStandards/PHP_CodeSniffer
|
||||
|
||||
[@bastianschwarz]: https://github.com/bastianschwarz
|
||||
[@BrianHenryIE]: https://github.com/BrianHenryIE
|
||||
[@christopher-hopper]: https://github.com/christopher-hopper
|
||||
[@fredden]: https://github.com/fredden
|
||||
[@frenck]: https://github.com/frenck
|
||||
[@gapple]: https://github.com/gapple
|
||||
[@GaryJones]: https://github.com/GaryJones
|
||||
[@GrahamCampbell]: https://github.com/GrahamCampbell
|
||||
[@jrfnl]: https://github.com/jrfnl
|
||||
[@kevinfodness]: https://github.com/kevinfodness
|
||||
[@mjrider]: https://github.com/mjrider
|
||||
[@ntwb]: https://github.com/ntwb
|
||||
[@paras-malhotra]: https://github.com/paras-malhotra
|
||||
[@Potherca]: https://github.com/Potherca
|
||||
[@Seldaek]: https://github.com/Seldaek
|
||||
[@SplotyCode]: https://github.com/SplotyCode
|
||||
[@srebb]: https://github.com/srebb
|
||||
[@TravisCarden]: https://github.com/TravisCarden
|
||||
22
vendor/dealerdirect/phpcodesniffer-composer-installer/LICENSE.md
vendored
Normal file
22
vendor/dealerdirect/phpcodesniffer-composer-installer/LICENSE.md
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2016-2022 Dealerdirect B.V. and contributors
|
||||
Copyright (c) 2022 PHPCSStandards and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
278
vendor/dealerdirect/phpcodesniffer-composer-installer/README.md
vendored
Normal file
278
vendor/dealerdirect/phpcodesniffer-composer-installer/README.md
vendored
Normal file
|
|
@ -0,0 +1,278 @@
|
|||
# PHP_CodeSniffer Standards Composer Installer Plugin
|
||||
|
||||
![Last Commit][last-updated-shield]
|
||||
![Awesome][awesome-shield]
|
||||
[![License][license-shield]](LICENSE.md)
|
||||
|
||||
[![Tests][ghactionstest-shield]][ghactions]
|
||||
[![Latest Version on Packagist][packagist-version-shield]][packagist-version]
|
||||
[![Packagist][packagist-shield]][packagist]
|
||||
|
||||
[![Contributor Covenant][code-of-conduct-shield]][code-of-conduct]
|
||||
|
||||
This composer installer plugin makes installation of [PHP_CodeSniffer][codesniffer] coding standards (rulesets) straight-forward.
|
||||
|
||||
No more symbolic linking of directories, checking out repositories on specific locations or manually changing the `phpcs` configuration.
|
||||
|
||||
## Usage
|
||||
|
||||
Installation can be done with [Composer][composer], by requiring this package as a development dependency:
|
||||
|
||||
```bash
|
||||
composer require --dev dealerdirect/phpcodesniffer-composer-installer:"^1.0"
|
||||
```
|
||||
|
||||
Since Composer 2.2, Composer will [ask for your permission](https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution) to allow this plugin to execute code. For this plugin to be functional, permission needs to be granted.
|
||||
|
||||
When permission has been granted, the following snippet will automatically be added to your `composer.json` file by Composer:
|
||||
```json
|
||||
{
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can safely add the permission flag (to avoid Composer needing to ask), by running:
|
||||
```bash
|
||||
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
|
||||
```
|
||||
|
||||
That's it.
|
||||
|
||||
### Compatibility
|
||||
|
||||
This plugin is compatible with:
|
||||
|
||||
- PHP **5.4+**, **7.x**, and **8.x** (Support for PHP v8 is available since [`v0.7.0`][v0.7])
|
||||
- [Composer][composer] **2.2+** (Support for Composer v2 is available since [`v0.7.0`][v0.7]; support for Composer < 2.2 was dropped in [`v1.1.0`][v1.1])
|
||||
- [PHP_CodeSniffer][codesniffer] **3.x** and **4.x**(Support for PHP_CodeSniffer v4 is available since [`v0.7.0`][v0.7], support for PHP_CodeSniffer v2 was dropped in [`v1.2.0`][v1.2])
|
||||
|
||||
### How it works
|
||||
|
||||
Basically, this plugin executes the following steps:
|
||||
|
||||
- This plugin searches for [`phpcodesniffer-standard` packages][] in all of your currently installed Composer packages.
|
||||
- Matching packages and the project itself are scanned for PHP_CodeSniffer rulesets.
|
||||
- The plugin will call PHP_CodeSniffer and configure the `installed_paths` option.
|
||||
|
||||
### Example project
|
||||
|
||||
The following is an example Composer project and has included
|
||||
multiple `phpcodesniffer-standard` packages.
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "example/project",
|
||||
"description": "Just an example project",
|
||||
"type": "project",
|
||||
"require": {},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "*",
|
||||
"phpcompatibility/php-compatibility": "*",
|
||||
"wp-coding-standards/wpcs": "*"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
After running `composer install` PHP_CodeSniffer just works:
|
||||
|
||||
```bash
|
||||
$ ./vendor/bin/phpcs -i
|
||||
The installed coding standards are PEAR, PSR1, PSR2, PSR12, Squiz, Zend, PHPCompatibility, Modernize,
|
||||
NormalizedArrays, Universal, PHPCSUtils, WordPress, WordPress-Core, WordPress-Docs and WordPress-Extra
|
||||
```
|
||||
|
||||
### Calling the plugin directly
|
||||
|
||||
In some circumstances, it is desirable to call this plugin's functionality
|
||||
directly. For instance, during development or in [CI][definition-ci] environments.
|
||||
|
||||
As the plugin requires Composer to work, direct calls need to be wired through a
|
||||
project's `composer.json`.
|
||||
|
||||
This is done by adding a call to the `Plugin::run` function in the `script`
|
||||
section of the `composer.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"install-codestandards": [
|
||||
"PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The command can then be called using `composer run-script install-codestandards` or
|
||||
referenced from other script configurations, as follows:
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"install-codestandards": [
|
||||
"PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
|
||||
],
|
||||
"post-install-cmd": [
|
||||
"@install-codestandards"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For more details about Composer scripts, please refer to [the section on scripts
|
||||
in the Composer manual][composer-manual-scripts].
|
||||
|
||||
### Changing the Coding Standards search depth
|
||||
|
||||
By default, this plugin searches up for Coding Standards up to three directories
|
||||
deep. In most cases, this should be sufficient. However, this plugin allows
|
||||
you to customize the search depth setting if needed.
|
||||
|
||||
```json
|
||||
{
|
||||
"extra": {
|
||||
"phpcodesniffer-search-depth": 5
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Caveats
|
||||
|
||||
When this plugin is installed globally, composer will load the _global_ plugin rather
|
||||
than the one from the local repository. Despite [this behavior being documented
|
||||
in the composer manual][using-composer-plugins], it could potentially confuse
|
||||
as another version of the plugin could be run and not the one specified by the project.
|
||||
|
||||
## Developing Coding Standards
|
||||
|
||||
Coding standard can be developed normally, as documented by [PHP_CodeSniffer][codesniffer], in the [Coding Standard Tutorial][tutorial].
|
||||
|
||||
Create a composer package of your coding standard by adding a `composer.json` file.
|
||||
|
||||
```json
|
||||
{
|
||||
"name" : "acme/phpcodesniffer-our-standards",
|
||||
"description" : "Package contains all coding standards of the Acme company",
|
||||
"require" : {
|
||||
"php" : ">=5.4.0",
|
||||
"squizlabs/php_codesniffer" : "^3.13"
|
||||
},
|
||||
"type" : "phpcodesniffer-standard"
|
||||
}
|
||||
```
|
||||
|
||||
Requirements:
|
||||
* The repository may contain one or more standards.
|
||||
* Each standard can have a separate directory no deeper than 3 levels from the repository root.
|
||||
* The package `type` must be `phpcodesniffer-standard`. Without this, the plugin will not trigger.
|
||||
|
||||
### Requiring the plugin from within your coding standard
|
||||
|
||||
If your coding standard itself depends on additional external PHPCS standards, this plugin can
|
||||
make life easier on your end-users by taking care of the installation of all standards - yours
|
||||
and your dependencies - for them.
|
||||
|
||||
This can help reduce the number of support questions about setting the `installed_paths`, as well
|
||||
as simplify your standard's installation instructions.
|
||||
|
||||
For this to work, make sure your external standard adds this plugin to the `composer.json` config
|
||||
via `require`, **not** `require-dev`.
|
||||
|
||||
> :warning: Your end-user may already `require-dev` this plugin and/or other external standards used
|
||||
> by your end-users may require this plugin as well.
|
||||
>
|
||||
> To prevent your end-users getting into "_dependency hell_", make sure to make the version requirement
|
||||
> for this plugin flexible.
|
||||
>
|
||||
> Remember that [Composer treats unstable minors as majors][composer-manual-caret] and will not be able to resolve
|
||||
> one config requiring this plugin at version `^0.7`, while another requires it at version `^1.0`.
|
||||
> Either allow multiple minors or use `*` as the version requirement.
|
||||
>
|
||||
> Some examples of flexible requirements which can be used:
|
||||
> ```bash
|
||||
> composer require dealerdirect/phpcodesniffer-composer-installer:"*"
|
||||
> composer require dealerdirect/phpcodesniffer-composer-installer:"^0.4.1 || ^0.5 || ^0.6 || ^0.7 || ^1.0"
|
||||
> ```
|
||||
|
||||
## Contributing
|
||||
|
||||
This is an active open-source project. We are always open to people who want to
|
||||
use the code or contribute to it.
|
||||
|
||||
We've set up a separate document for our [contribution guidelines][contributing-guidelines].
|
||||
|
||||
Thank you for being involved! :heart_eyes:
|
||||
|
||||
## Authors & contributors
|
||||
|
||||
The original idea and setup of this repository is by [Franck Nijhof][frenck], employee @ Dealerdirect.
|
||||
|
||||
For a full list of all authors and/or contributors, check [the contributors page][contributors].
|
||||
|
||||
## Funding
|
||||
|
||||
This project is included in the projects supported via the [PHP_CodeSniffer Open Collective][phpcs-open-collective].
|
||||
|
||||
If you use this plugin, financial contributions to the Open Collective are encouraged and appreciated.
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-2022 Dealerdirect B.V. and contributors
|
||||
Copyright (c) 2022- PHPCSStandards and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
[awesome-shield]: https://img.shields.io/badge/awesome%3F-yes-brightgreen.svg
|
||||
[code-of-conduct-shield]: https://img.shields.io/badge/Contributor%20Covenant-v2.0-ff69b4.svg
|
||||
[code-of-conduct]: CODE_OF_CONDUCT.md
|
||||
[codesniffer]: https://github.com/PHPCSStandards/PHP_CodeSniffer
|
||||
[composer-manual-scripts]: https://getcomposer.org/doc/articles/scripts.md
|
||||
[composer-manual-caret]: https://getcomposer.org/doc/articles/versions.md#caret-version-range-
|
||||
[composer]: https://getcomposer.org/
|
||||
[contributing-guidelines]: CONTRIBUTING.md
|
||||
[contributors]: https://github.com/PHPCSStandards/composer-installer/graphs/contributors
|
||||
[definition-ci]: https://en.wikipedia.org/wiki/Continuous_integration
|
||||
[frenck]: https://github.com/frenck
|
||||
[last-updated-shield]: https://img.shields.io/github/last-commit/PHPCSStandards/composer-installer.svg
|
||||
[license-shield]: https://img.shields.io/github/license/PHPCSStandards/composer-installer.svg
|
||||
[packagist-shield]: https://img.shields.io/packagist/dt/dealerdirect/phpcodesniffer-composer-installer.svg
|
||||
[packagist-version-shield]: https://img.shields.io/packagist/v/dealerdirect/phpcodesniffer-composer-installer.svg
|
||||
[packagist-version]: https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer
|
||||
[packagist]: https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer
|
||||
[`phpcodesniffer-standard` packages]: https://packagist.org/explore/?type=phpcodesniffer-standard
|
||||
[phpcs-open-collective]: https://opencollective.com/php_codesniffer
|
||||
[scrutinizer-shield]: https://img.shields.io/scrutinizer/g/dealerdirect/phpcodesniffer-composer-installer.svg
|
||||
[scrutinizer]: https://scrutinizer-ci.com/g/dealerdirect/phpcodesniffer-composer-installer/
|
||||
[ghactionstest-shield]: https://github.com/PHPCSStandards/composer-installer/actions/workflows/integrationtest.yml/badge.svg
|
||||
[ghactions]: https://github.com/PHPCSStandards/composer-installer/actions/workflows/integrationtest.yml
|
||||
[tutorial]: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial
|
||||
[using-composer-plugins]: https://getcomposer.org/doc/articles/plugins.md#using-plugins
|
||||
[v0.7]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v0.7.0
|
||||
[v1.1]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v1.1.0
|
||||
[v1.2]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v1.2.0
|
||||
631
vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php
vendored
Normal file
631
vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php
vendored
Normal file
|
|
@ -0,0 +1,631 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Dealerdirect PHP_CodeSniffer Standards
|
||||
* Composer Installer Plugin package.
|
||||
*
|
||||
* @copyright 2016-2022 Dealerdirect B.V.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace PHPCSStandards\Composer\Plugin\Installers\PHPCodeSniffer;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\EventDispatcher\EventSubscriberInterface;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\RootPackageInterface;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
use Composer\Script\Event;
|
||||
use Composer\Script\ScriptEvents;
|
||||
use Composer\Util\Filesystem;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Process\Exception\LogicException;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
|
||||
/**
|
||||
* PHP_CodeSniffer standard installation manager.
|
||||
*
|
||||
* @author Franck Nijhof <franck.nijhof@dealerdirect.com>
|
||||
*/
|
||||
class Plugin implements PluginInterface, EventSubscriberInterface
|
||||
{
|
||||
const KEY_MAX_DEPTH = 'phpcodesniffer-search-depth';
|
||||
|
||||
const MESSAGE_ERROR_WRONG_MAX_DEPTH =
|
||||
'The value of "%s" (in the composer.json "extra".section) must be an integer larger than %d, %s given.';
|
||||
|
||||
const MESSAGE_NOT_INSTALLED = 'PHPCodeSniffer is not installed';
|
||||
const MESSAGE_NOTHING_TO_INSTALL = 'No PHPCS standards to install or update';
|
||||
const MESSAGE_PLUGIN_UNINSTALLED = 'PHPCodeSniffer Composer Installer is uninstalled';
|
||||
const MESSAGE_RUNNING_INSTALLER = 'Running PHPCodeSniffer Composer Installer';
|
||||
|
||||
const PACKAGE_NAME = 'squizlabs/php_codesniffer';
|
||||
const PACKAGE_TYPE = 'phpcodesniffer-standard';
|
||||
|
||||
const PHPCS_CONFIG_REGEX = '`%s:[^\r\n]+`';
|
||||
const PHPCS_CONFIG_KEY = 'installed_paths';
|
||||
|
||||
const PLUGIN_NAME = 'dealerdirect/phpcodesniffer-composer-installer';
|
||||
|
||||
/**
|
||||
* @var Composer
|
||||
*/
|
||||
private $composer;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $cwd;
|
||||
|
||||
/**
|
||||
* @var Filesystem
|
||||
*/
|
||||
private $filesystem;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $installedPaths;
|
||||
|
||||
/**
|
||||
* @var IOInterface
|
||||
*/
|
||||
private $io;
|
||||
|
||||
/**
|
||||
* @var ProcessExecutor
|
||||
*/
|
||||
private $processExecutor;
|
||||
|
||||
/**
|
||||
* Triggers the plugin's main functionality.
|
||||
*
|
||||
* Makes it possible to run the plugin as a custom command.
|
||||
*
|
||||
* @param Event $event
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RuntimeException
|
||||
* @throws LogicException
|
||||
* @throws ProcessFailedException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function run(Event $event)
|
||||
{
|
||||
$io = $event->getIO();
|
||||
$composer = $event->getComposer();
|
||||
|
||||
$instance = new static();
|
||||
|
||||
$instance->io = $io;
|
||||
$instance->composer = $composer;
|
||||
$instance->init();
|
||||
$instance->onDependenciesChangedEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws LogicException
|
||||
* @throws ProcessFailedException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function activate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
$this->composer = $composer;
|
||||
$this->io = $io;
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deactivate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function uninstall(Composer $composer, IOInterface $io)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the plugin so it's main functionality can be run.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws LogicException
|
||||
* @throws ProcessFailedException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function init()
|
||||
{
|
||||
$this->cwd = getcwd();
|
||||
$this->installedPaths = array();
|
||||
|
||||
$this->processExecutor = new ProcessExecutor($this->io);
|
||||
$this->filesystem = new Filesystem($this->processExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
ScriptEvents::POST_INSTALL_CMD => array(
|
||||
array('onDependenciesChangedEvent', 0),
|
||||
),
|
||||
ScriptEvents::POST_UPDATE_CMD => array(
|
||||
array('onDependenciesChangedEvent', 0),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for post install and post update events.
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws LogicException
|
||||
* @throws ProcessFailedException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function onDependenciesChangedEvent()
|
||||
{
|
||||
$io = $this->io;
|
||||
$isVerbose = $io->isVerbose();
|
||||
$exitCode = 0;
|
||||
|
||||
if ($isVerbose) {
|
||||
$io->write(sprintf('<info>%s</info>', self::MESSAGE_RUNNING_INSTALLER));
|
||||
}
|
||||
|
||||
if ($this->isPHPCodeSnifferInstalled() === true) {
|
||||
$this->loadInstalledPaths();
|
||||
$installPathCleaned = $this->cleanInstalledPaths();
|
||||
$installPathUpdated = $this->updateInstalledPaths();
|
||||
|
||||
if ($installPathCleaned === true || $installPathUpdated === true) {
|
||||
$exitCode = $this->saveInstalledPaths();
|
||||
} elseif ($isVerbose) {
|
||||
$io->write(sprintf('<info>%s</info>', self::MESSAGE_NOTHING_TO_INSTALL));
|
||||
}
|
||||
} else {
|
||||
$pluginPackage = $this
|
||||
->composer
|
||||
->getRepositoryManager()
|
||||
->getLocalRepository()
|
||||
->findPackages(self::PLUGIN_NAME)
|
||||
;
|
||||
|
||||
$isPluginUninstalled = count($pluginPackage) === 0;
|
||||
|
||||
if ($isPluginUninstalled) {
|
||||
if ($isVerbose) {
|
||||
$io->write(sprintf('<info>%s</info>', self::MESSAGE_PLUGIN_UNINSTALLED));
|
||||
}
|
||||
} else {
|
||||
$exitCode = 1;
|
||||
if ($isVerbose) {
|
||||
$io->write(sprintf('<error>%s</error>', self::MESSAGE_NOT_INSTALLED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $exitCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all paths from PHP_CodeSniffer into an array.
|
||||
*
|
||||
* @throws LogicException
|
||||
* @throws ProcessFailedException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function loadInstalledPaths()
|
||||
{
|
||||
if ($this->isPHPCodeSnifferInstalled() === true) {
|
||||
$this->processExecutor->execute(
|
||||
$this->getPhpcsCommand() . ' --config-show',
|
||||
$output,
|
||||
$this->getPHPCodeSnifferInstallPath()
|
||||
);
|
||||
|
||||
$regex = sprintf(self::PHPCS_CONFIG_REGEX, self::PHPCS_CONFIG_KEY);
|
||||
if (preg_match($regex, $output, $match) === 1) {
|
||||
$phpcsInstalledPaths = str_replace(self::PHPCS_CONFIG_KEY . ': ', '', $match[0]);
|
||||
$phpcsInstalledPaths = trim($phpcsInstalledPaths);
|
||||
|
||||
if ($phpcsInstalledPaths !== '') {
|
||||
$this->installedPaths = explode(',', $phpcsInstalledPaths);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all coding standard paths back into PHP_CodeSniffer
|
||||
*
|
||||
* @throws LogicException
|
||||
* @throws ProcessFailedException
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @return int Exit code. 0 for success, 1 or higher for failure.
|
||||
*/
|
||||
private function saveInstalledPaths()
|
||||
{
|
||||
// Check if we found installed paths to set.
|
||||
if (count($this->installedPaths) !== 0) {
|
||||
sort($this->installedPaths);
|
||||
$paths = implode(',', $this->installedPaths);
|
||||
$arguments = array('--config-set', self::PHPCS_CONFIG_KEY, $paths);
|
||||
$configMessage = sprintf(
|
||||
'PHP CodeSniffer Config <info>%s</info> <comment>set to</comment> <info>%s</info>',
|
||||
self::PHPCS_CONFIG_KEY,
|
||||
$paths
|
||||
);
|
||||
} else {
|
||||
// Delete the installed paths if none were found.
|
||||
$arguments = array('--config-delete', self::PHPCS_CONFIG_KEY);
|
||||
$configMessage = sprintf(
|
||||
'PHP CodeSniffer Config <info>%s</info> <comment>delete</comment>',
|
||||
self::PHPCS_CONFIG_KEY
|
||||
);
|
||||
}
|
||||
|
||||
// Prepare message in case of failure
|
||||
$failMessage = sprintf(
|
||||
'Failed to set PHP CodeSniffer <info>%s</info> Config',
|
||||
self::PHPCS_CONFIG_KEY
|
||||
);
|
||||
|
||||
// Okay, lets rock!
|
||||
$command = vsprintf(
|
||||
'%s %s',
|
||||
array(
|
||||
'phpcs command' => $this->getPhpcsCommand(),
|
||||
'arguments' => implode(' ', $arguments),
|
||||
)
|
||||
);
|
||||
|
||||
$exitCode = $this->processExecutor->execute($command, $configResult, $this->getPHPCodeSnifferInstallPath());
|
||||
if ($exitCode === 0) {
|
||||
$exitCode = $this->verifySaveSuccess();
|
||||
}
|
||||
|
||||
if ($exitCode === 0) {
|
||||
$this->io->write($configMessage);
|
||||
} else {
|
||||
$this->io->write($failMessage);
|
||||
}
|
||||
|
||||
if ($this->io->isVerbose() && !empty($configResult)) {
|
||||
$this->io->write(sprintf('<info>%s</info>', $configResult));
|
||||
}
|
||||
|
||||
return $exitCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the paths which were expected to be saved, have been.
|
||||
*
|
||||
* @return int Exit code. 0 for success, 1 for failure.
|
||||
*/
|
||||
private function verifySaveSuccess()
|
||||
{
|
||||
$exitCode = 1;
|
||||
$expectedPaths = $this->installedPaths;
|
||||
|
||||
// Request the currently set installed paths after the save.
|
||||
$this->loadInstalledPaths();
|
||||
|
||||
$registeredPaths = array_intersect($this->installedPaths, $expectedPaths);
|
||||
$registeredCount = count($registeredPaths);
|
||||
$expectedCount = count($expectedPaths);
|
||||
|
||||
if ($expectedCount === $registeredCount) {
|
||||
$exitCode = 0;
|
||||
}
|
||||
|
||||
if ($exitCode === 1 && $this->io->isVerbose()) {
|
||||
$verificationMessage = sprintf(
|
||||
"Paths to external standards found by the plugin: <info>%s</info>\n"
|
||||
. 'Actual paths registered with PHPCS: <info>%s</info>',
|
||||
implode(', ', $expectedPaths),
|
||||
implode(', ', $this->installedPaths)
|
||||
);
|
||||
$this->io->write($verificationMessage);
|
||||
}
|
||||
|
||||
return $exitCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the command to call PHPCS.
|
||||
*/
|
||||
protected function getPhpcsCommand()
|
||||
{
|
||||
return vsprintf(
|
||||
'%s %s',
|
||||
array(
|
||||
'php executable' => $this->getPhpExecCommand(),
|
||||
'phpcs executable' => './bin/phpcs',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the current PHP version being used.
|
||||
*
|
||||
* Duplicate of the same in the EventDispatcher class in Composer itself.
|
||||
*/
|
||||
protected function getPhpExecCommand()
|
||||
{
|
||||
$finder = new PhpExecutableFinder();
|
||||
|
||||
$phpPath = $finder->find(false);
|
||||
|
||||
if ($phpPath === false) {
|
||||
throw new \RuntimeException('Failed to locate PHP binary to execute ' . $phpPath);
|
||||
}
|
||||
|
||||
$phpArgs = $finder->findArguments();
|
||||
$phpArgs = $phpArgs
|
||||
? ' ' . implode(' ', $phpArgs)
|
||||
: ''
|
||||
;
|
||||
|
||||
$command = ProcessExecutor::escape($phpPath) .
|
||||
$phpArgs .
|
||||
' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen')) .
|
||||
' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions')) .
|
||||
' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'))
|
||||
;
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate trough all known paths and check if they are still valid.
|
||||
*
|
||||
* If path does not exists, is not an directory or isn't readable, the path
|
||||
* is removed from the list.
|
||||
*
|
||||
* @return bool True if changes where made, false otherwise
|
||||
*/
|
||||
private function cleanInstalledPaths()
|
||||
{
|
||||
$changes = false;
|
||||
foreach ($this->installedPaths as $key => $path) {
|
||||
// Resolve relative paths to absolute using the PHPCS install path as the base
|
||||
// to avoid potential open_basedir warnings from is_dir() on relative paths.
|
||||
if ($this->filesystem->isAbsolutePath($path) === false) {
|
||||
$path = realpath($this->getPHPCodeSnifferInstallPath() . \DIRECTORY_SEPARATOR . $path);
|
||||
}
|
||||
|
||||
if ($path === false || is_dir($path) === false || is_readable($path) === false) {
|
||||
unset($this->installedPaths[$key]);
|
||||
$changes = true;
|
||||
}
|
||||
}
|
||||
return $changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check all installed packages (including the root package) against
|
||||
* the installed paths from PHP_CodeSniffer and add the missing ones.
|
||||
*
|
||||
* @return bool True if changes where made, false otherwise
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
private function updateInstalledPaths()
|
||||
{
|
||||
$changes = false;
|
||||
$searchPaths = array();
|
||||
|
||||
// Add root package only if it has the expected package type.
|
||||
if (
|
||||
$this->composer->getPackage() instanceof RootPackageInterface
|
||||
&& $this->composer->getPackage()->getType() === self::PACKAGE_TYPE
|
||||
) {
|
||||
$searchPaths[] = $this->cwd;
|
||||
}
|
||||
|
||||
$codingStandardPackages = $this->getPHPCodingStandardPackages();
|
||||
foreach ($codingStandardPackages as $package) {
|
||||
$installPath = $this->composer->getInstallationManager()->getInstallPath($package);
|
||||
if ($this->filesystem->isAbsolutePath($installPath) === false) {
|
||||
$installPath = $this->filesystem->normalizePath(
|
||||
$this->cwd . \DIRECTORY_SEPARATOR . $installPath
|
||||
);
|
||||
}
|
||||
$searchPaths[] = $installPath;
|
||||
}
|
||||
|
||||
// Nothing to do.
|
||||
if ($searchPaths === array()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->files()
|
||||
->depth('<= ' . $this->getMaxDepth())
|
||||
->depth('>= ' . $this->getMinDepth())
|
||||
->ignoreUnreadableDirs()
|
||||
->ignoreVCS(true)
|
||||
->in($searchPaths)
|
||||
->name('ruleset.xml');
|
||||
|
||||
// Process each found possible ruleset.
|
||||
foreach ($finder as $ruleset) {
|
||||
$standardsPath = $ruleset->getPath();
|
||||
|
||||
// Pick the directory above the directory containing the standard, unless this is the project root.
|
||||
if ($standardsPath !== $this->cwd) {
|
||||
$standardsPath = dirname($standardsPath);
|
||||
}
|
||||
|
||||
// Use relative paths for local project repositories.
|
||||
if ($this->isRunningGlobally() === false) {
|
||||
$standardsPath = $this->filesystem->findShortestPath(
|
||||
$this->getPHPCodeSnifferInstallPath(),
|
||||
$standardsPath,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// De-duplicate and add when directory is not configured.
|
||||
if (in_array($standardsPath, $this->installedPaths, true) === false) {
|
||||
$this->installedPaths[] = $standardsPath;
|
||||
$changes = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through Composers' local repository looking for valid Coding
|
||||
* Standard packages.
|
||||
*
|
||||
* @return array Composer packages containing coding standard(s)
|
||||
*/
|
||||
private function getPHPCodingStandardPackages()
|
||||
{
|
||||
$codingStandardPackages = array_filter(
|
||||
$this->composer->getRepositoryManager()->getLocalRepository()->getPackages(),
|
||||
function (PackageInterface $package) {
|
||||
if ($package instanceof AliasPackage) {
|
||||
return false;
|
||||
}
|
||||
return $package->getType() === Plugin::PACKAGE_TYPE;
|
||||
}
|
||||
);
|
||||
|
||||
return $codingStandardPackages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for the installed PHP_CodeSniffer Composer package
|
||||
*
|
||||
* @param null|string|\Composer\Semver\Constraint\ConstraintInterface $versionConstraint to match against
|
||||
*
|
||||
* @return PackageInterface|null
|
||||
*/
|
||||
private function getPHPCodeSnifferPackage($versionConstraint = null)
|
||||
{
|
||||
$packages = $this
|
||||
->composer
|
||||
->getRepositoryManager()
|
||||
->getLocalRepository()
|
||||
->findPackages(self::PACKAGE_NAME, $versionConstraint);
|
||||
|
||||
return array_shift($packages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the PHP_CodeSniffer package installation location
|
||||
*
|
||||
* {@internal Do NOT try to modernize via the Composer 2.2 API (`InstalledVersions::getInstallPath()`).
|
||||
* Doing so doesn't play nice with other plugins.
|
||||
* {@link https://github.com/PHPCSStandards/composer-installer/issues/239}}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getPHPCodeSnifferInstallPath()
|
||||
{
|
||||
return $this->composer->getInstallationManager()->getInstallPath($this->getPHPCodeSnifferPackage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple check if PHP_CodeSniffer is installed.
|
||||
*
|
||||
* {@internal Do NOT try to modernize via the Composer 2.2 API (`InstalledVersions::isInstalled()`).
|
||||
* Doing so doesn't play nice with integrations calling the Composer EventDispatcher programmatically.
|
||||
* {@link https://github.com/PHPCSStandards/composer-installer/issues/247}}
|
||||
*
|
||||
* @param null|string|\Composer\Semver\Constraint\ConstraintInterface $versionConstraint to match against
|
||||
*
|
||||
* @return bool Whether PHP_CodeSniffer is installed
|
||||
*/
|
||||
private function isPHPCodeSnifferInstalled($versionConstraint = null)
|
||||
{
|
||||
return ($this->getPHPCodeSnifferPackage($versionConstraint) !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if composer is running "global"
|
||||
* This check kinda dirty, but it is the "Composer Way"
|
||||
*
|
||||
* @return bool Whether Composer is running "globally"
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
private function isRunningGlobally()
|
||||
{
|
||||
return ($this->composer->getConfig()->get('home') === $this->cwd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the maximum search depth when searching for Coding Standards.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function getMaxDepth()
|
||||
{
|
||||
$maxDepth = 3;
|
||||
|
||||
$extra = $this->composer->getPackage()->getExtra();
|
||||
|
||||
if (array_key_exists(self::KEY_MAX_DEPTH, $extra)) {
|
||||
$maxDepth = $extra[self::KEY_MAX_DEPTH];
|
||||
$minDepth = $this->getMinDepth();
|
||||
|
||||
if (
|
||||
(string) (int) $maxDepth !== (string) $maxDepth /* Must be an integer or cleanly castable to one */
|
||||
|| $maxDepth <= $minDepth /* Larger than the minimum */
|
||||
|| is_float($maxDepth) === true /* Within the boundaries of integer */
|
||||
) {
|
||||
$message = vsprintf(
|
||||
self::MESSAGE_ERROR_WRONG_MAX_DEPTH,
|
||||
array(
|
||||
'key' => self::KEY_MAX_DEPTH,
|
||||
'min' => $minDepth,
|
||||
'given' => var_export($maxDepth, true),
|
||||
)
|
||||
);
|
||||
|
||||
throw new \InvalidArgumentException($message);
|
||||
}
|
||||
}
|
||||
|
||||
return (int) $maxDepth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimal search depth for Coding Standard packages.
|
||||
*
|
||||
* Usually this is 0, unless PHP_CodeSniffer >= 3 is used.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getMinDepth()
|
||||
{
|
||||
if ($this->isPHPCodeSnifferInstalled('>= 3.0.0') !== true) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue