diff --git a/src/Exporter.php b/src/Exporter.php index ffedb3e..e6a24bd 100644 --- a/src/Exporter.php +++ b/src/Exporter.php @@ -69,10 +69,10 @@ public function shortenedRecursiveExport(array &$data, ?RecursionContext $proces $overallCount = count($data, COUNT_RECURSIVE); $counter = 0; - $export = $this->shortenedCountedRecursiveExport($data, $processed, $overallCount, $counter); + $export = $this->shortenedCountedRecursiveExport($data, $processed, $counter); if ($overallCount > $this->shortenArraysLongerThan) { - $export .= sprintf(' ...%d more elements', $overallCount - $this->shortenArraysLongerThan); + $export .= sprintf(', ...%d more elements', $overallCount - $this->shortenArraysLongerThan); } return $export; @@ -189,7 +189,7 @@ public function toArray(mixed $value): array return $array; } - private function shortenedCountedRecursiveExport(array &$data, RecursionContext $processed, int $overallCount, int &$counter): string + private function shortenedCountedRecursiveExport(array &$data, RecursionContext $processed, int &$counter): string { $result = []; @@ -199,7 +199,7 @@ private function shortenedCountedRecursiveExport(array &$data, RecursionContext $processed->add($data); foreach ($array as $key => $value) { - if ($overallCount > $this->shortenArraysLongerThan && $counter > $this->shortenArraysLongerThan) { + if ($counter > $this->shortenArraysLongerThan) { break; } @@ -207,7 +207,7 @@ private function shortenedCountedRecursiveExport(array &$data, RecursionContext if ($processed->contains($data[$key]) !== false) { $result[] = '*RECURSION*'; } else { - $result[] = '[' . $this->shortenedCountedRecursiveExport($data[$key], $processed, $overallCount, $counter) . ']'; + $result[] = '[' . $this->shortenedCountedRecursiveExport($data[$key], $processed, $counter) . ']'; } } else { $result[] = $this->shortenedExport($value); diff --git a/tests/ExporterTest.php b/tests/ExporterTest.php index d99572d..4eb52e0 100644 --- a/tests/ExporterTest.php +++ b/tests/ExporterTest.php @@ -342,8 +342,8 @@ public static function shortenedRecursiveExportProvider(): array 'with assoc array key' => [['foo' => 'bar'], '\'bar\''], 'multidimensional array' => [[[1, 2, 3], [3, 4, 5]], '[1, 2, 3], [3, 4, 5]'], 'object' => [[new stdClass], 'stdClass Object ()'], - 'big array' => [$bigArray, "'cast('foo0' as blob)', 'cast('foo1' as blob)', 'cast('foo2' as blob)', 'cast('foo3' as blob)', 'cast('foo4' as blob)', 'cast('foo5' as blob)', 'cast('foo6' as blob)', 'cast('foo7' as blob)', 'cast('foo8' as blob)', 'cast('foo9' as blob)', 'cast('foo10' as blob)' ...19990 more elements"], - 'deep array' => [$deepArray, "[1, 2, 'hello', 'world', true, false], [[1, 2, 'hello', 'world']] ...69 more elements"], + 'big array' => [$bigArray, "'cast('foo0' as blob)', 'cast('foo1' as blob)', 'cast('foo2' as blob)', 'cast('foo3' as blob)', 'cast('foo4' as blob)', 'cast('foo5' as blob)', 'cast('foo6' as blob)', 'cast('foo7' as blob)', 'cast('foo8' as blob)', 'cast('foo9' as blob)', 'cast('foo10' as blob)', ...19990 more elements"], + 'deep array' => [$deepArray, "[1, 2, 'hello', 'world', true, false], [[1, 2, 'hello', 'world']], ...69 more elements"], ]; }