This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
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.
This PR adds the
SlevomatCodingStandard.Variables.UnusedVariable
sniff, which detects unused variables. See the unusedVariableErrors.php test file for a number of examples that are detected by this tool.For key/value pairs in a foreach statement where only the key is used, no violation is reported when the value is unused (this required setting the
ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach
property totrue
).So the following file does not generate an error:
Note that the following still generates an error, because the key is unused:
The following error is reported:
NB This PR upgrades the Slevomat Coding Standard to v7.0.19, which fixes a few issues in this sniff (#1320 and #1321).