PHPCSStandards / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
857 stars 53 forks source link

Keep Installed Paths When Upgrading Versions #259

Closed Ouroboros2460 closed 7 months ago

Ouroboros2460 commented 7 months ago

Is your feature request related to a problem?

I use a custom standard and set it via

phpcs --config-set installed_paths PATH
phpcs --config-set default_standard STANDARD

Whenever I upgrade the package (which I am guessing will happen more often now; thanks for that!), I need to re-run these commands.

Describe the solution you'd like

Persist these config settings upon upgrade.

Additional context (optional)

I use brew to upgrade this package. I see: https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/8ffe4035898c506ecab8109f24f2f26e9b1292ec/scripts/build-phar.php#L94 so I may try to take a stab at this.

jrfnl commented 7 months ago

@Ouroboros2460 I don't know how brew installs PHPCS. If brew destroys the CodeSniffer.conf file, that would be something to report there.

Ouroboros2460 commented 7 months ago

Hmm ok. I was talking to someone who was having the same behavior with composer update so I assumed brew was not to blame. I can check with him on Monday then I can see if this can be closed if that is ok? Pretty sure the brew installation commands happen here: https://github.com/Homebrew/homebrew-core/blob/40d438abc15209ac2d70764edca5f5ca6edf4637/Formula/p/php-code-sniffer.rb but I am pretty sure the files end up in a new folder path with the version in the path, so it would make sense that CodeSniffer.conf is missing.

jrfnl commented 7 months ago

@Ouroboros2460 Please do check.

As for Composer - there is a Composer plugin available which can register all standards in the same Composer install, so that is the recommended way for preserving the installed_paths setting on a Composer upgrade.

Ouroboros2460 commented 7 months ago

It looks like you are correct. The config file lives at /usr/local/Cellar/php-code-sniffer/3.8.1/bin/CodeSniffer.conf on an Intel Mac, so I get a new one every version.

Thanks for the heads up about the plugin; maybe I will switch to using composer.