PHPCSStandards / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
880 stars 54 forks source link

Correct error code in Squiz.ControlStructures.ForEachLoopDeclaration #582

Open fredden opened 1 month ago

fredden commented 1 month ago

Description

From what we can determine, this is a typographical error / mistake. It seems that the intention here was to use the same error code for both sides of this if/else block.

This inconsistency was detected as part of reviewing a fixer conflict with the PSR12 standard and the src/Standards/Squiz/Tests/ControlStructures/ForEachLoopDeclarationUnitTest.inc test file. See https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/152#issuecomment-2227504202 for full details on this conflict and https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/152#issuecomment-2255751041 for a decision on how to move forward / resolve the inconsistency.

Note that we are not fixing other inconsistencies in this sniff as doing so would have little return on investment.

Suggested changelog entry

Squiz.ControlStructures.ForEachLoopDeclaration: change error code from SpacingAfterOpen to SpaceAfterOpen. The latter is an existing code and the former seems to have been a typographical error.

Related issues/external references

152

Types of changes

PR checklist