Skip to content

Commit af9a34f

Browse files
committed
Merge branch 'feature/phpcs-set-array-values' of https://github.com/webimpress/PHP_CodeSniffer
2 parents ebc013c + 7575ad9 commit af9a34f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/Files/File.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public function process()
352352
$start = strpos($commentText, '@codingStandardsChangeSetting');
353353
$comment = substr($commentText, ($start + 30));
354354
$parts = explode(' ', $comment);
355-
if (count($parts) >= 3) {
355+
if (count($parts) >= 2) {
356356
$sniffParts = explode('.', $parts[0]);
357357
if (count($sniffParts) >= 3) {
358358
// If the sniff code is not known to us, it has not been registered in this run.
@@ -388,7 +388,7 @@ public function process()
388388

389389
// Need to maintain case here, to get the correct sniff code.
390390
$parts = explode(' ', substr($commentText, 10));
391-
if (count($parts) >= 3) {
391+
if (count($parts) >= 2) {
392392
$sniffParts = explode('.', $parts[0]);
393393
if (count($sniffParts) >= 3) {
394394
// If the sniff code is not known to us, it has not been registered in this run.

src/Ruleset.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,11 +1263,30 @@ public function setSniffProperty($sniffClass, $name, $value)
12631263
$value = trim($value);
12641264
}
12651265

1266+
if ($value === '') {
1267+
$value = null;
1268+
}
1269+
12661270
// Special case for booleans.
12671271
if ($value === 'true') {
12681272
$value = true;
12691273
} else if ($value === 'false') {
12701274
$value = false;
1275+
} else if (substr($name, -2) === '[]') {
1276+
$name = substr($name, 0, -2);
1277+
$values = [];
1278+
if ($value !== null) {
1279+
foreach (explode(',', $value) as $val) {
1280+
list($k, $v) = explode('=>', $val.'=>');
1281+
if ($v !== '') {
1282+
$values[trim($k)] = trim($v);
1283+
} else {
1284+
$values[] = trim($k);
1285+
}
1286+
}
1287+
}
1288+
1289+
$value = $values;
12711290
}
12721291

12731292
$this->sniffs[$sniffClass]->$name = $value;

0 commit comments

Comments
 (0)