From 6e4f9017367375d3bef4d0499caf043234f02198 Mon Sep 17 00:00:00 2001 From: Roger Krolow Date: Thu, 6 Oct 2016 22:34:23 -0300 Subject: [PATCH] Update PhpReports.php Replace preg_replace with /e, which is DEPRECATED in PHP 5.6.26, with preg_replace_callback. --- lib/PhpReports/PhpReports.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/PhpReports/PhpReports.php b/lib/PhpReports/PhpReports.php index 8a921d87..ac106c30 100644 --- a/lib/PhpReports/PhpReports.php +++ b/lib/PhpReports/PhpReports.php @@ -648,10 +648,12 @@ public static function load($dir, $skip=array()) { */ public static function json_decode($json, $assoc=false) { //replace single quoted values - $json = preg_replace('/:\s*\'(([^\']|\\\\\')*)\'\s*([},])/e', "':'.json_encode(stripslashes('$1')).'$3'", $json); + $callback = function ($matches) { return ':'.json_encode(stripslashes('$matches[1]')).'$matches[3]'; } ; + $json = preg_replace_callback('/:\s*\'(([^\']|\\\\\')*)\'\s*([},])/', $callback, $json); //replace single quoted keys - $json = preg_replace('/\'(([^\']|\\\\\')*)\'\s*:/e', "json_encode(stripslashes('$1')).':'", $json); + $callback = function ($matches) { return json_encode(stripslashes('$matches[1]')).':'; } ; + $json = preg_replace_callback('/\'(([^\']|\\\\\')*)\'\s*:/', $callback, $json); //remove any line breaks in the code $json = str_replace(array("\n","\r"),"",$json);