1

ECS = symplify/easy-coding-standard
I am getting an message when running ECS:

Unused variable $validator.
(SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff.UnusedVariable)

For this code:

// phpcs:ignore
// @codingStandardsIgnoreLine
foreach ($this->rules as $attribute => $validator) {

I did try using the suppress comments in different setup:

  • only one of them
  • on the same line as the message suggests
  • in different order
  • by targeting specific warning:
    • SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff.UnusedVariable
    • SlevomatCodingStandard.Variables.UnusedVariable

Does any one know if ECS supports inline suppress comments?
In the ECS documentation I see it's only possible to suppress whole file.

PS. I know I can use array_keys(), but the goal in this case is to suppress the warnings, as in the future it can be a different one.

1 Answer 1

2

Or... as variant add rule to config file easy-coding-standard.yaml

services:
  SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff:
    ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach: true
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.