Skip to content

Commit 8bba8fa

Browse files
committed
Merge branch 'master' into 3.0
2 parents 493a70a + 26d3516 commit 8bba8fa

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
108108
- Fixed bug #1109 : Wrong scope indent reported in anonymous class
109109
- Fixed bug #1112 : File docblock not recognized when require_once follows it
110110
- Fixed bug #1120 : InlineControlStructureSniff does not handle auto-fixing for control structures that make function calls
111+
- Fixed bug #1124 : Squiz.Operators.ComparisonOperatorUsage does not detect bracketed conditions for inline IF statements
112+
-- Thanks to Raphael Horber for the patch
111113
</notes>
112114
<contents>
113115
<dir name="/">

src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function process(File $phpcsFile, $stackPtr)
121121

122122
$start = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
123123
} else {
124-
if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) {
124+
if (isset($tokens[$end]['parenthesis_opener']) === false) {
125125
return;
126126
}
127127

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,15 @@ while (TRUE) {
117117

118118
while (FALSE) {
119119
}
120+
121+
$var = ($var1 === true) ? $var1 : "foobar";
122+
123+
$var = ($var1 == true) ? $var1 : "foobar";
124+
125+
$var = ($var1 === false) ? $var1 : "foobar";
126+
127+
$var = ($var1 == false) ? $var1 : "foobar";
128+
129+
$var = ($var1 === 0) ? $var1 : "foobar";
130+
131+
$var = ($var1 == 0) ? $var1 : "foobar";

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,15 @@ for (one = 10; one !== 0; one--) {
5757

5858
for (type in types) {
5959
}
60+
61+
variable = (variable2 === true) ? variable1 : "foobar";
62+
63+
variable = (variable2 == true) ? variable1 : "foobar";
64+
65+
variable = (variable2 === false) ? variable1 : "foobar";
66+
67+
variable = (variable2 == false) ? variable1 : "foobar";
68+
69+
variable = (variable2 === 0) ? variable1 : "foobar";
70+
71+
variable = (variable2 == 0) ? variable1 : "foobar";

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc')
5454
100 => 1,
5555
106 => 1,
5656
112 => 1,
57+
123 => 1,
58+
127 => 1,
59+
131 => 1,
5760
);
5861
break;
5962
case 'ComparisonOperatorUsageUnitTest.js':
@@ -66,6 +69,9 @@ public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc')
6669
40 => 1,
6770
47 => 1,
6871
52 => 1,
72+
63 => 1,
73+
67 => 1,
74+
71 => 1,
6975
);
7076
break;
7177
default:

0 commit comments

Comments
 (0)