Ruleset: handle invalid sniffs more graciously #873
Merged
+172
−0
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
As things were, a ruleset loading an invalid sniff - a sniff which doesn't implement the
Sniff
interface and is missing either theregister()
orprocess()
method, or both -, would result in fatal errors which are unfriendly to the end-user.Now, while this will hopefully be a very rare occurrence and should no longer be possible as of PHPCS 4.0, which intends to remove support for sniffs not implementing the
Sniff
interface, I still believe it prudent to show more user-friendly and more informative error messages to the end-user until that time.This commit implements this and executes step 2 to address issue #694.
Includes tests.
Output of commands involving various invalid sniffs before this PR:
Output of commands involving various invalid sniffs after this PR:
Suggested changelog entry
The user will be shown an informative error message for sniffs are missing one of the required methods.
Previously this would result in a fatal error.
Related issues/external references
Related to #694