From f3b1df00bf369ff8c125783a6267159e681c2df9 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 7 Jun 2018 15:06:04 +0200 Subject: [PATCH] Fix CS/WS issues --- src/Framework/Constraint/ArraySubset.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Framework/Constraint/ArraySubset.php b/src/Framework/Constraint/ArraySubset.php index bdf68e43742..a785046911c 100644 --- a/src/Framework/Constraint/ArraySubset.php +++ b/src/Framework/Constraint/ArraySubset.php @@ -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); @@ -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 @@ -149,6 +154,8 @@ private function deepSort(array &$array): void } } + unset($value); + if ($this->isAssociative($array)) { \ksort($array); } else { @@ -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;