Commit ce3b3840 authored by Kevin Herrera's avatar Kevin Herrera

Fixing use of fourth argument in json_decode() for PHP <5.4.

parent 93f43393
......@@ -24,6 +24,7 @@
"phpunit/phpunit": "3.7.*"
},
"autoload": {
"files": ["src/lib/json_version.php"],
"psr-0": {
"Herrera\\Json": "src/lib"
}
......
......@@ -53,7 +53,11 @@ class Json
*/
public function decode($json, $assoc = false, $depth = 512, $options = 0)
{
$data = json_decode($json, $assoc, $depth, $options);
if (JSON_DECODE_FOURTH_ARG) {
$data = json_decode($json, $assoc, $depth, $options);
} else {
$data = json_decode($json, $assoc, $depth);
}
if (JSON_ERROR_NONE !== ($error = json_last_error())) {
if (JSON_ERROR_UTF8 === $error) {
......
<?php
/**
* The flag used to control the use of the fourth argument for json_decode().
*
* @var boolean
*/
define('JSON_DECODE_FOURTH_ARG', version_compare(phpversion(), '5.4.0', '>='));
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment