Skip to content

Commit

Permalink
Merge branch 'feature/phpcs-set-array-values' of https://github.com/w…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jun 1, 2018
2 parents ebc013c + 7575ad9 commit af9a34f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function process()
$start = strpos($commentText, '@codingStandardsChangeSetting');
$comment = substr($commentText, ($start + 30));
$parts = explode(' ', $comment);
if (count($parts) >= 3) {
if (count($parts) >= 2) {
$sniffParts = explode('.', $parts[0]);
if (count($sniffParts) >= 3) {
// If the sniff code is not known to us, it has not been registered in this run.
Expand Down Expand Up @@ -388,7 +388,7 @@ public function process()

// Need to maintain case here, to get the correct sniff code.
$parts = explode(' ', substr($commentText, 10));
if (count($parts) >= 3) {
if (count($parts) >= 2) {
$sniffParts = explode('.', $parts[0]);
if (count($sniffParts) >= 3) {
// If the sniff code is not known to us, it has not been registered in this run.
Expand Down
19 changes: 19 additions & 0 deletions src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -1263,11 +1263,30 @@ public function setSniffProperty($sniffClass, $name, $value)
$value = trim($value);
}

if ($value === '') {
$value = null;
}

// Special case for booleans.
if ($value === 'true') {
$value = true;
} else if ($value === 'false') {
$value = false;
} else if (substr($name, -2) === '[]') {
$name = substr($name, 0, -2);
$values = [];
if ($value !== null) {
foreach (explode(',', $value) as $val) {
list($k, $v) = explode('=>', $val.'=>');
if ($v !== '') {
$values[trim($k)] = trim($v);
} else {
$values[] = trim($k);
}
}
}

$value = $values;
}

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

0 comments on commit af9a34f

Please sign in to comment.