Skip to content

Commit aa156a0

Browse files
committed
Fix tests for earlier PHP versions
1 parent 20368ad commit aa156a0

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ apply to following calls.
241241
Maximum number of levels when encoding arrays and objects. Exception is
242242
thrown when the maximum is exceeded. Set to `false` to have no limit.
243243

244+
## Known Issues ##
245+
246+
If you are running this library on a PHP version earlier than 5.4.5, you may
247+
receive the following error, if you are trying to encode a recursive array:
248+
249+
`Fatal error: Nesting level too deep - recursive dependency?`
250+
251+
In order to fix this, it is recommended to disable `recursion.detect` and set
252+
a max value for `recursion.max` if you expect to encounter recursive arrays.
253+
244254
## Credits ##
245255

246256
This library is copyright 2013 - 2015 to Riikka Kalliomäki.

tests/tests/EncodingTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ public function testFloatExponents()
9696
public function testPHPDefaultPrecision()
9797
{
9898
$float = 1.12345678901234567890;
99+
100+
$cast = ini_set('precision', 17);
101+
$serialize = ini_set('serialize_precision', 17);
102+
99103
$this->assertEncode(var_export($float, true), $float, ['float.precision' => false]);
104+
105+
ini_set('precision', $cast);
106+
ini_set('serialize_precision', $serialize);
100107
}
101108

102109
public function testInfiniteFloat()
@@ -249,6 +256,10 @@ public function testUnknownType()
249256

250257
public function testArrayRecursion()
251258
{
259+
if (version_compare(PHP_VERSION, '5.4.5', '<')) {
260+
$this->markTestSkipped();
261+
}
262+
252263
$foo = [1];
253264
$foo[1] = & $foo;
254265

@@ -258,6 +269,10 @@ public function testArrayRecursion()
258269

259270
public function testIgnoredArrayRecursion()
260271
{
272+
if (version_compare(PHP_VERSION, '5.4.5', '<')) {
273+
$this->markTestSkipped();
274+
}
275+
261276
$foo = [1];
262277
$foo[1] = & $foo;
263278

0 commit comments

Comments
 (0)