Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: loadInstalledPaths() very very broken since PHPCS 3.1.0 #98

Merged
merged 1 commit into from
Jan 19, 2020

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jan 19, 2020

Proposed Changes

Discovered while debugging the build failure of #97

The PHPCS --config-show command shows all config settings set, not just the installed_paths and since PHPCS 3.1.0, it also includes a line to indicate which configuration file is being used to help with debugging configuration issues.

Example:

Using config file: I:/path/to/project/vendor/squizlabs/php_codesniffer/CodeSniffer.conf

default_standard:  Squiz
installed_paths:   ../../phpcompatibility/php-compatibility
show_progress:     1

In PHPCS 2.0 - 3.0.1, if any other configuration options were set, aside from installed_paths, the result of the loadInstalledPaths() command would be broken.

In PHPCS 3.1.0+, the result would always be broken, no matter what.

In effect this means that the installed_paths would (nearly) always be set as if the config was previously non-existent as the cleanInstalledPaths() method would empty out the array as the values contained therein would be invalid anyway.

It would be lovely if it were possible to add unit tests, but as we're talking about a private method setting a private property...

So, for now, to proof the bug and validate the fix, I've set up a "fake" unit test to demonstrate what the previous behaviour was and what the behaviour will be with this fix in place: https://3v4l.org/brrNT

I suspect that this may fix some mystery issues previously reported.

@jrfnl jrfnl requested review from Potherca and mjrider January 19, 2020 00:56
@jrfnl jrfnl force-pushed the feature/bug-fix-loadInstalledPaths branch from 5e8a561 to a5f1082 Compare January 19, 2020 01:11
src/Plugin.php Outdated Show resolved Hide resolved
src/Plugin.php Outdated Show resolved Hide resolved
The PHPCS `--config-show` command shows **all** config settings set, not just the `installed_paths` and since PHPCS 3.1.0, it also includes a line to indicate which configuration file is being used to help with debugging configuration issues.

In PHPCS 2.0 - 3.0.1, if any [other configuration options](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options) were set, the result of the `loadInstalledPaths()` command would be broken.

In PHPCS 3.1.0+, the result would always be broken, no matter what.

In effect this means that the `installed_paths` would (nearly) always be set as if the config was previously non-existent as the `cleanInstalledPaths()` method would empty out the array as the values contained therein would be invalid anyway.

It would be lovely if it were possible to add unit tests, but as we're talking about a `private` method setting a `private` property...

So, for now, to proof the bug and validate the fix, I've set up a "fake" unit test to demonstrate what the previous behaviour was and what the behaviour will be with this fix in place: https://3v4l.org/XKMIf
@jrfnl jrfnl force-pushed the feature/bug-fix-loadInstalledPaths branch from a5f1082 to b09c763 Compare January 19, 2020 14:10
@Potherca Potherca merged commit 3942e1a into master Jan 19, 2020
@jrfnl jrfnl deleted the feature/bug-fix-loadInstalledPaths branch January 19, 2020 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants