Skip to content

Commit 8c5f82a

Browse files
committed
Require variables defined in for loop initial assignment and in while condition not to be used after the loop
1 parent 95d9d2a commit 8c5f82a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
* Require booleans in `if`, `elseif`, ternary operator, after `!`, and on both sides of `&&` and `||`.
1010
* Functions `in_array` and `array_search` must be called with third parameter `$strict` set to `true` to search values with matching types only.
11+
* Variables assigned in `while` loop condition and `for` loop initial assignment cannot be used after the loop.
1112

1213
Additional rules are coming in subsequent releases!
1314

rules.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
parameters:
2+
polluteScopeWithLoopInitialAssignments: false
3+
14
services:
25
-
36
class: PHPStan\Rules\BooleansInConditions\BooleanInBooleanAndRule

0 commit comments

Comments
 (0)