Skip to content

Commit e5dc4ee

Browse files
committed
Merge pull request #2 from Riimu/php7
Ensure that tests pass on php7 & hhvm
2 parents aa156a0 + cb55202 commit e5dc4ee

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ php:
55
- 5.6
66
- 5.5
77
- 5.4
8+
- 7.0
9+
- hhvm
810

911
cache:
1012
directories:
@@ -14,8 +16,8 @@ before_install:
1416
- composer self-update
1517

1618
install:
17-
- composer require --no-update --no-interaction "phpunit/phpunit:4.*" "squizlabs/php_codesniffer:2.*" "fabpot/php-cs-fixer:1.*"
18-
- travis_retry composer install --no-interaction
19+
- composer require --no-update --no-interaction "phpunit/phpunit:*" "squizlabs/php_codesniffer:*" "fabpot/php-cs-fixer:*"
20+
- travis_retry composer install --no-interaction --prefer-source
1921
- travis_retry wget https://scrutinizer-ci.com/ocular.phar
2022

2123
script:
@@ -24,4 +26,4 @@ script:
2426
- vendor/bin/php-cs-fixer fix --dry-run --diff
2527

2628
after_script:
27-
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
29+
- if [ -f coverage.clover ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,23 @@ apply to following calls.
243243

244244
## Known Issues ##
245245

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:
246+
### Recursive arrays on PHP < 5.4.5 ###
247+
248+
If you try to encode recursive arrays on PHP versions earlier than 5.4.5, you
249+
may encounter the following error (due to the way array comparisons work
250+
internally in PHP):
248251

249252
`Fatal error: Nesting level too deep - recursive dependency?`
250253

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.
254+
In order to fix this, you should disable the recursive array detection by
255+
setting the option `recursion.detect` to false and set a value for the option
256+
`recursion.max` to prevent recursive arrays from causing an infinite loop.
257+
258+
### Float precision on HHVM ###
259+
260+
Note that HHVM does not support the ini setting `serialize_precision`. Thus,
261+
the use of the value `false` for the option `float.precision` is not supported
262+
on HHVM.
253263

254264
## Credits ##
255265

tests/tests/EncodingTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,17 @@ public function testFloatExponents()
9393
$this->assertEncode('-1.0E-32', -1.0e-32);
9494
}
9595

96-
public function testPHPDefaultPrecision()
96+
public function testUsingIniPrecision()
9797
{
98-
$float = 1.12345678901234567890;
98+
if (defined('HHVM_VERSION')) {
99+
$this->markTestSkipped();
100+
}
99101

100-
$cast = ini_set('precision', 17);
101-
$serialize = ini_set('serialize_precision', 17);
102+
$float = 1.1234567890123456;
103+
$serialize = ini_set('serialize_precision', 13);
102104

103-
$this->assertEncode(var_export($float, true), $float, ['float.precision' => false]);
105+
$this->assertEncode('1.123456789012', $float, ['float.precision' => false]);
104106

105-
ini_set('precision', $cast);
106107
ini_set('serialize_precision', $serialize);
107108
}
108109

0 commit comments

Comments
 (0)