Skip to content

Commit

Permalink
Closes #61
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 18, 2024
1 parent f278802 commit 7eb922f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.

## [6.1.1] - 2024-06-18

### Fixed

* [#61](https://github.com/sebastianbergmann/exporter/issues/61): `count(): Recursion detected` warning triggered

## [6.1.0] - 2024-06-18

### Added
Expand Down Expand Up @@ -134,6 +140,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

* Remove HHVM-specific code that is no longer needed

[6.1.1]: https://github.com/sebastianbergmann/exporter/compare/6.1.0...6.1.1
[6.1.0]: https://github.com/sebastianbergmann/exporter/compare/6.0.3...6.1.0
[6.0.3]: https://github.com/sebastianbergmann/exporter/compare/fe0dca49a60d34440e2f086951952dd13aa9a5d2...6.0.3
[6.0.2]: https://github.com/sebastianbergmann/exporter/compare/6.0.1...fe0dca49a60d34440e2f086951952dd13aa9a5d2
Expand Down
2 changes: 1 addition & 1 deletion src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function shortenedRecursiveExport(array &$data, ?RecursionContext $proces
$processed = new RecursionContext;
}

$overallCount = count($data, COUNT_RECURSIVE);
$overallCount = @count($data, COUNT_RECURSIVE);
$counter = 0;

$export = $this->shortenedCountedRecursiveExport($data, $processed, $counter);
Expand Down
18 changes: 18 additions & 0 deletions tests/ExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public static function exportProvider(): array
$resource = fopen('php://memory', 'r');
fclose($resource);

$recursiveArray = [];
$recursiveArray[0] = &$recursiveArray;

return [
'null' => [null, 'null', 0],
'boolean true' => [true, 'true', 0],
Expand Down Expand Up @@ -273,6 +276,17 @@ public static function exportProvider(): array
'SebastianBergmann\Exporter\ExampleIntegerBackedEnum Enum #%d (Value, 0)',
0,
],
'recursive array' => [
$recursiveArray,
<<<'EOF'
Array &0 [
0 => Array &1 [
0 => Array &1,
],
]
EOF,
0,
],
];
}

Expand All @@ -285,6 +299,9 @@ public static function shortenedExportProvider(): array
'foo' => 'bar',
];

$recursiveArray = [];
$recursiveArray[0] = &$recursiveArray;

return [
'null' => [null, 'null'],
'boolean true' => [true, 'true'],
Expand All @@ -307,6 +324,7 @@ public static function shortenedExportProvider(): array
'enum' => [ExampleEnum::Value, 'SebastianBergmann\Exporter\ExampleEnum Enum (Value)'],
'backed enum (string)' => [ExampleStringBackedEnum::Value, 'SebastianBergmann\Exporter\ExampleStringBackedEnum Enum (Value, \'value\')'],
'backen enum (integer)' => [ExampleIntegerBackedEnum::Value, 'SebastianBergmann\Exporter\ExampleIntegerBackedEnum Enum (Value, 0)'],
'recursive array' => [$recursiveArray, '[...]', 0],
];
}

Expand Down

0 comments on commit 7eb922f

Please sign in to comment.