-
-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
Description
I'd like to re-open the discussion around whether the paths registered with PHPCS should be absolute or relative paths.
Some previous issues related to this: #14, #33, #73
Current status after #28:
- Global installs use absolute paths
- Local installs use relative paths
Problems I'm seeing
- In some tests on Windows, I'm seeing duplicate relative paths being registered, i.e.:
As this will result in the same standard(s) being registered twice with PHPCS, this is likely to cause problems with the autoloading of sniffs.
Using config file: C:\\Users\\runneradmin\\AppData\\Local\\Temp\\PHPCSPluginTest\\RegisterExternalStandardsTest_61fe56765bc692.23339840\\local\\vendor\\squizlabs\\php_codesniffer\\CodeSniffer.conf installed_paths: ../../../../../../../../../../RUNNER~1/AppData/Local/Temp/PHPCSPluginTest/RegisterExternalStandardsTest_61fe56765bc692.23339840/local/vendor/phpcs-composer-installer,../../phpcs-composer-installer - Even without duplicate paths, I've had reports of relative paths causing problems with the PHPCS autoloading of sniffs: Unable to get stock install working, cannot declare class errors PHPCompatibility/PHPCompatibility#1311 (comment)
Proposal
Always use absolute paths.
Further research needed
- What about projects in a dual OS setup, like Windows with WSL or a Vagrant environment ?
- What about projects with a committed
vendordirectory ?
=> I'd like to suggest that they can add a script to run this plugin to theircomposer.jsonand can run that script whenever the project is checked out. After all, the plugin will update the paths based on the runtime environment, so should fix the paths in the committedCodeSniffer.Conffile to the new environment. - Can this be made easier ?
=> In Composer 2.x, Plugins can add their own commands to Composer. We could consider adding a custom command to run this plugin. This would negate the need to add the script.
Ref: https://getcomposer.org/doc/articles/plugins.md#command-provider - Should there still be an option for users to use relative paths ?
=> Along the same lines as the search-depth option, we could consider adding aforce-relative-pathsoption.
We should probably also investigate if custom commands can take custom arguments. In that case, we could possible add support for a--force-relative-pathsCLI argument if needs be.
Reactions are currently unavailable