Skip to content

Commit 580e9de

Browse files
committed
PHP 8.0 | Generic/AssignmentInCondition: include match expressions
Allows the sniff to also check for assignments in condition in the condition part of a match expression. Includes unit test.
1 parent 8b0137a commit 580e9de

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function register()
6060
T_SWITCH,
6161
T_CASE,
6262
T_WHILE,
63+
T_MATCH,
6364
];
6465

6566
}//end register()

src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ while ( $sample = false ) {}
9191

9292
if ($a = 123) :
9393
endif;
94+
95+
match ($a[0] = 123) {};

src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getWarningList()
7474
88 => 1,
7575
90 => 1,
7676
92 => 1,
77+
95 => 1,
7778
];
7879

7980
}//end getWarningList()

0 commit comments

Comments
 (0)