sirbrillig / phpcs-changed

🐘 Run phpcs on files and only report new warnings/errors compared to the previous version.
MIT License
31 stars 11 forks source link

Request :: Add PHPCS executable path as a parameter #70

Closed bplv112 closed 1 year ago

bplv112 commented 1 year ago

I'll start off by mentioning that this package has made my life drastically easier. So THANK YOU for that.

I was using this package for bitbucket pipelines and I realized that instead of looking for phpcs in the vendor directory it searches for a global executable. I saw that we could fix this using PHPCS env var but can we simplify this by making it check vendor folder first and then look for the executable globally?

Or could we add a new parameter where we can add phpcs executable path. Its probably subjective because I hate touching env vars ( ironic I know ) but this would definitely simplify the usage.

Again, thank you for the package, love the work! <3

sirbrillig commented 1 year ago

Thanks! So it sounds like there's two related but separate suggestions here that I'll try to summarize. Let me know if this sounds right.

  1. If the PHPCS env variable is not set, and there is a vendor/bin directory in the current directory which contains a phpcs executable, use that instead of assuming phpcs is in the PATH.
  2. Add an option like --phpcs=./vendor/bin/phpcs which overrides the PHPCS env variable.

Number 1 sounds like a great idea!

As for number 2, that would also be fairly easy to do. Just out of curiosity, what would be the UX difference between commands like PHPCS=./vendor/bin/phpcs phpcs-changed --git file.php and phpcs-changed --phpcs=./vendor/bin/phpcs --git file.php? Is it easier to do the latter in some situation that I'm not thinking of?

bplv112 commented 1 year ago

Thank you! I feel like phpcs-changed --phpcs=./vendor/bin/phpcs --git file.php would be easier for me personally to use and that's what I feel could be easier in general as well since it will be mentioned on the command help and on the documentation.

sirbrillig commented 1 year ago

Number 2 (adding options for overriding paths) will be fixed by https://github.com/sirbrillig/phpcs-changed/pull/79

sirbrillig commented 1 year ago

Number 1 (phpcs vendor auto-detection) will be fixed by https://github.com/sirbrillig/phpcs-changed/pull/81

sirbrillig commented 1 year ago

https://github.com/sirbrillig/phpcs-changed/releases/tag/v2.11.0-beta.1 should include both of these changes. I'll do a full release when I'm sure that I haven't broken anything. If you have a chance to try it out, @bplv112, let me know!