diff --git a/src/Ruleset.php b/src/Ruleset.php index d1ef2a4d75..7614998171 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -1215,7 +1215,7 @@ private function processRule($rule, $newSniffs, $depth=0) } $value = (string) $element['value']; - if (isset($element['key']) === true) { + if (isset($element['key']) === true && trim($element['key']) !== '') { $key = (string) $element['key']; $values[$key] = $value; $printValue .= $key.'=>'.$value.','; diff --git a/tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc b/tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc index 31caeb6198..e40ecf3c4c 100644 --- a/tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc +++ b/tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc @@ -20,12 +20,12 @@ // phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsBooleanFalseCase fALSe // phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsBooleanFalseTrimmed false -// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithOnlyValues[] string, 10, 1.5, null, true, false -// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithKeysAndValues[] string=>string,10=>10,float=>1.5,null=>null,true=>true,false=>false +// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithOnlyValues[] string, 10, 1.5, , null, true, false +// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsArrayWithKeysAndValues[] string=>string,10=>10,float=>1.5,=>,null=>null,true=>true,false=>false // phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsEmptyArray[] -// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsOldSchoolArrayWithOnlyValues[] string, 10, 1.5, null, true, false -// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsOldSchoolArrayWithKeysAndValues[] string=>string,10=>10,float=>1.5,null=>null,true=>true,false=>false +// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsOldSchoolArrayWithOnlyValues[] string, 10, 1.5, , null, true, false +// phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsOldSchoolArrayWithKeysAndValues[] string=>string,10=>10,float=>1.5,=>,null=>null,true=>true,false=>false // phpcs:set TestStandard.SetProperty.PropertyTypeHandling expectsOldSchoolEmptyArray[] echo 'hello!'; diff --git a/tests/Core/Ruleset/PropertyTypeHandlingTest.php b/tests/Core/Ruleset/PropertyTypeHandlingTest.php index 1db15aa5d2..de71ba3980 100644 --- a/tests/Core/Ruleset/PropertyTypeHandlingTest.php +++ b/tests/Core/Ruleset/PropertyTypeHandlingTest.php @@ -120,6 +120,7 @@ public static function dataTypeHandling() 'string', '10', '1.5', + '', 'null', 'true', 'false', @@ -128,6 +129,7 @@ public static function dataTypeHandling() 'string' => 'string', 10 => '10', 'float' => '1.5', + 11 => '', 'null' => 'null', 'true' => 'true', 'false' => 'false', diff --git a/tests/Core/Ruleset/PropertyTypeHandlingTest.xml b/tests/Core/Ruleset/PropertyTypeHandlingTest.xml index 2e89a37b55..eaca667532 100644 --- a/tests/Core/Ruleset/PropertyTypeHandlingTest.xml +++ b/tests/Core/Ruleset/PropertyTypeHandlingTest.xml @@ -25,6 +25,7 @@ + @@ -34,6 +35,7 @@ + @@ -60,9 +62,9 @@ - + - +