Skip to content

Commit 659c6bf

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 a949e13 commit 659c6bf

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
@@ -136,3 +136,10 @@ if (empty($argTags > 0)) {
136136
}
137137

138138
myFunction($var1 === true ? "" : "foobar");
139+
140+
$anon = new class(!$foo ? 0 : 1, ($bar == true) ? 1 : 0) {
141+
function __construct($a, $b) {}
142+
};
143+
$anon = new class($foo === false ? 0 : 1, ($bar === true) ? 1 : 0) {
144+
function __construct($a, $b) {}
145+
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function getErrorList()
5454
127 => 1,
5555
131 => 1,
5656
135 => 1,
57+
140 => 2,
5758
];
5859

5960
}//end getErrorList()

0 commit comments

Comments
 (0)