You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generic/InlineControlStructure: removed another unnecessary code block
The original version of this part of the code that is now being removed
was added in the early days by the commit that enabled this sniff to fix
errors:
squizlabs/PHP_CodeSniffer@a54c619#diff-4b3945c2100b0a92a56509de1b797bf58ad804cf36233c95c492479b665655dcR148-R154
The only two tests that were added with the commit mentioned above
that trigger the removed condition are tests using `while` loops
without body:
squizlabs/PHP_CodeSniffer@a54c619#diff-116c49a7b0b31f724fc25409e31ba119d7f023146818bcb63edbe8f4071422e2R42-R43
Control structures without a body are the only cases where `$next`
would be equal to `$end`. Thus, these are the only cases where the
removed condition would be executed. But two previous commits, changed
the sniff to bail early and not get to the fixer part when handling
control structures without a body. 13c803b changed the sniff to ignore
while/for without a body and updated the existing tests
(squizlabs/PHP_CodeSniffer@13c803b#diff-2f069f3fe33bacdfc80485b97303aec66c98c451d07e6d86e41982b81ab1a294L49-R50).
a495c2cc expanded the same approach for else/elseif/if/foreach control
structures.
After the removal of the `$next !== $end`, the `$next` variable became
used allowing to further simplify the code by removing the place where
it was being defined.
Note for reviewers: this commit is easier to evaluate when ignoring
whitespaces.
0 commit comments