Skip to content

Commit 4c5ace4

Browse files
committed
ComparisonOperatorUsage: add test with anonymous class
.. to document that the sniff also handles comparisons passed in the instantiation of an anonymous class.
1 parent 483fca2 commit 4c5ace4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,10 @@ if (true) {}
152152
if (\true) {}
153153
for ($var1 = 10; FALSE; $var1--) {}
154154
for ($var1 = 10; \FALSE; $var1--) {}
155+
156+
$anon = new class(!$foo ? 0 : 1, ($bar == true) ? 1 : 0) {
157+
function __construct($a, $b) {}
158+
};
159+
$anon = new class($foo === false ? 0 : 1, ($bar === true) ? 1 : 0) {
160+
function __construct($a, $b) {}
161+
};

src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function getErrorList()
6363
146 => 1,
6464
147 => 1,
6565
148 => 1,
66+
156 => 2,
6667
];
6768

6869
}//end getErrorList()

0 commit comments

Comments
 (0)