Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',';
Expand Down
8 changes: 4 additions & 4 deletions tests/Core/Ruleset/Fixtures/PropertyTypeHandlingInline.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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!';
2 changes: 2 additions & 0 deletions tests/Core/Ruleset/PropertyTypeHandlingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static function dataTypeHandling()
'string',
'10',
'1.5',
'',
'null',
'true',
'false',
Expand All @@ -128,6 +129,7 @@ public static function dataTypeHandling()
'string' => 'string',
10 => '10',
'float' => '1.5',
11 => '',
'null' => 'null',
'true' => 'true',
'false' => 'false',
Expand Down
6 changes: 4 additions & 2 deletions tests/Core/Ruleset/PropertyTypeHandlingTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<element value="string"/>
<element value="10"/>
<element value="1.5"/>
<element value=""/>
<element value="null"/>
<element value="true"/>
<element value="false"/>
Expand All @@ -34,6 +35,7 @@
<element key="string" value="string"/>
<element key="10" value="10"/>
<element key="float" value="1.5"/>
<element key="" value=""/>
<element key="null" value="null"/>
<element key="true" value="true"/>
<element key="false" value="false"/>
Expand All @@ -60,9 +62,9 @@

<property name="expectsEmptyArray" type="array"/>

<property name="expectsOldSchoolArrayWithOnlyValues" type="array" value="string, 10, 1.5, null, true, false" />
<property name="expectsOldSchoolArrayWithOnlyValues" type="array" value="string, 10, 1.5, , null, true, false" />

<property name="expectsOldSchoolArrayWithKeysAndValues" type="array" value="string=>string,10=>10,float=>1.5,null=>null,true=>true,false=>false" />
<property name="expectsOldSchoolArrayWithKeysAndValues" type="array" value="string=>string,10=>10,float=>1.5,=>,null=>null,true=>true,false=>false" />

<property name="expectsOldSchoolArrayWithExtendedValues" type="array" value="string" />
<property name="expectsOldSchoolArrayWithExtendedValues" type="array" extend="true" value="15,another string" />
Expand Down
Loading