Config: show user friendly error message when ini change failed #1024
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Inspired by discussion #415.
Previously, when a PHP ini option which cannot be changed at runtime was passed to PHPCS, it would be silently ignored (by PHP, PHPCS would still try to handle it, but would not report that PHP did not change the value).
This commit changes that behaviour by adding a new "ERROR: Ini option %s cannot be set at runtime" error to alert the end-user to the fact that they are passing a PHP ini option which PHPCS cannot change.
The new error will be thrown both when the user passes the invalid ini setting via the command line, as well as when it is passed via a custom ruleset.
The behaviour when trying to change an ini setting which doesn't exist (typo, extension not available) is unchanged. In that case, the ini directive will still be silently ignored.
Includes unit tests to safeguard the new behaviour.
Also note: when this error occurs due to an invalid setting being passed via a ruleset, the error will be thrown directly and not collected via the
MessageCollector
. This is due to the error coming from theConfig
class. Once theMessageCollector
would be implemented in theConfig
class, this can potentially be changed.Suggested changelog entry
Added:
An error will be shown when attempting to change an unchangable PHP ini setting using
-d option[=value]
or via the ruleset with<ini name=...>
.- Previously, this was silently ignored.
- Attempting to change non-existent ini settings (typo, extension not loaded) will continue to be silently ignored.
Related issues/external references
Closes #416