Skip to content

Commit 038abb6

Browse files
committed
Merge branch 'master' into 4.x
2 parents 872430f + 38a40fd commit 038abb6

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/Ruleset.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,15 +1651,13 @@ public function setSniffProperty($sniffClass, $name, $settings)
16511651
// Handle properties set inline via phpcs:set.
16521652
if (substr($name, -2) === '[]') {
16531653
$values = [];
1654-
if (is_string($value) === true) {
1655-
if (trim($value) !== '') {
1656-
foreach (explode(',', $value) as $val) {
1657-
list($k, $v) = explode('=>', $val.'=>');
1658-
if ($v !== '') {
1659-
$values[trim($k)] = $v;
1660-
} else {
1661-
$values[] = $k;
1662-
}
1654+
if (is_string($value) === true && trim($value) !== '') {
1655+
foreach (explode(',', $value) as $val) {
1656+
if (strpos($val, '=>') === false) {
1657+
$values[] = $val;
1658+
} else {
1659+
list($k, $v) = explode('=>', $val);
1660+
$values[trim($k)] = $v;
16631661
}
16641662
}
16651663
}

tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsBooleanFalseCase fALSe
2222
// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsBooleanFalseTrimmed false
2323

24-
// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithOnlyValues[] string, 10, 1.5, null, true, false
25-
// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithKeysAndValues[] string=>string,10=>10,float=>1.5,null=>null,true=>true,false=>false
24+
// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithOnlyValues[] string, 10, 1.5, , null, true, false
25+
// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithKeysAndValues[] string=>string,10=>10,float=>1.5,=>,null=>null,true=>true,false=>false
2626
// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsEmptyArray[]
2727

2828
// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithJustValueTrue[] true

tests/Core/Ruleset/PropertyTypeHandlingTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ public static function dataTypeHandling()
9393
'10',
9494
'1.5',
9595
null,
96+
null,
9697
true,
9798
false,
9899
];
99100
$expectedArrayKeysAndValues = [
100101
'string' => 'string',
101102
10 => '10',
102103
'float' => '1.5',
104+
'' => null,
103105
'null' => null,
104106
'true' => true,
105107
'false' => false,

tests/Core/Ruleset/PropertyTypeHandlingTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<element value="string"/>
2727
<element value="10"/>
2828
<element value="1.5"/>
29+
<element value=""/>
2930
<element value="null"/>
3031
<element value="true"/>
3132
<element value="false"/>
@@ -35,6 +36,7 @@
3536
<element key="string" value="string"/>
3637
<element key="10" value="10"/>
3738
<element key="float" value="1.5"/>
39+
<element key="" value=""/>
3840
<element key="null" value="null"/>
3941
<element key="true" value="true"/>
4042
<element key="false" value="false"/>

0 commit comments

Comments
 (0)