Skip to content

Commit

Permalink
Fix CS/WS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 7, 2018
1 parent 84d01bb commit f3b1df0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Framework/Constraint/ArraySubset.php
Expand Up @@ -65,6 +65,7 @@ public function evaluate($other, $description = '', $returnResult = false)
$this->subset = $this->toArray($this->subset);

$intersect = $this->arrayIntersectRecursive($other, $this->subset);

$this->deepSort($intersect);
$this->deepSort($this->subset);

Expand Down Expand Up @@ -131,9 +132,13 @@ private function toArray(iterable $other): array

private function isAssociative(array $array): bool
{
return \array_reduce(\array_keys($array), function (bool $carry, $key): bool {
return $carry || \is_string($key);
}, false);
return \array_reduce(
\array_keys($array),
function (bool $carry, $key): bool {
return $carry || \is_string($key);
},
false
);
}

private function compare($first, $second): bool
Expand All @@ -149,6 +154,8 @@ private function deepSort(array &$array): void
}
}

unset($value);

if ($this->isAssociative($array)) {
\ksort($array);
} else {
Expand Down Expand Up @@ -192,10 +199,7 @@ private function arrayIntersectRecursive(array $array, array $subset): array
}
} else {
foreach ($subset as $key => $subset_value) {
if (!\is_array($subset_value) && $this->compare(
$subset_value,
$array_value
)) {
if (!\is_array($subset_value) && $this->compare($subset_value, $array_value)) {
$intersect[$key] = $array_value;

break;
Expand Down

0 comments on commit f3b1df0

Please sign in to comment.