Added support PHP 7.1
This commit is contained in:
@@ -155,22 +155,14 @@ class Manager
|
||||
* Reads entire file into a string
|
||||
*
|
||||
* @param string | array $path Ex. 'path.php' OR array('dir', 'path.php')
|
||||
* @param boolean $useIncludePath
|
||||
* @param resource $context
|
||||
* @param integer $offset
|
||||
* @param integer $maxlen
|
||||
* @return mixed
|
||||
*/
|
||||
public function getContents($path, $useIncludePath = false, $context = null, $offset = -1, $maxlen = null)
|
||||
public function getContents($path)
|
||||
{
|
||||
$fullPath = $this->concatPaths($path);
|
||||
|
||||
if (file_exists($fullPath)) {
|
||||
if (isset($maxlen)) {
|
||||
return file_get_contents($fullPath, $useIncludePath, $context, $offset, $maxlen);
|
||||
} else {
|
||||
return file_get_contents($fullPath, $useIncludePath, $context, $offset);
|
||||
}
|
||||
return file_get_contents($fullPath);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -200,11 +192,10 @@ class Manager
|
||||
* @param string | array $path
|
||||
* @param mixed $data
|
||||
* @param integer $flags
|
||||
* @param resource $context
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function putContents($path, $data, $flags = 0, $context = null)
|
||||
public function putContents($path, $data, $flags = 0)
|
||||
{
|
||||
$fullPath = $this->concatPaths($path); //todo remove after changing the params
|
||||
|
||||
@@ -212,7 +203,7 @@ class Manager
|
||||
throw new Error('Permission denied for '. $fullPath);
|
||||
}
|
||||
|
||||
$res = (file_put_contents($fullPath, $data, $flags, $context) !== FALSE);
|
||||
$res = (file_put_contents($fullPath, $data, $flags) !== FALSE);
|
||||
if ($res && function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($fullPath);
|
||||
}
|
||||
|
||||
@@ -36,12 +36,11 @@ class Json
|
||||
*
|
||||
* @param string $value
|
||||
* @param int $options Default 0
|
||||
* @param int $depth Default 512
|
||||
* @return string
|
||||
*/
|
||||
public static function encode($value, $options = 0, $depth = 512)
|
||||
public static function encode($value, $options = 0)
|
||||
{
|
||||
$json = json_encode($value, $options, $depth);
|
||||
$json = json_encode($value, $options);
|
||||
|
||||
$error = self::getLastError();
|
||||
if ($json === null || !empty($error)) {
|
||||
@@ -56,11 +55,9 @@ class Json
|
||||
*
|
||||
* @param string $json
|
||||
* @param bool $assoc Default false
|
||||
* @param int $depth Default 512
|
||||
* @param int $options Default 0
|
||||
* @return object
|
||||
* @return object|array
|
||||
*/
|
||||
public static function decode($json, $assoc = false, $depth = 512, $options = 0)
|
||||
public static function decode($json, $assoc = false)
|
||||
{
|
||||
if (is_null($json) || $json === false) {
|
||||
return $json;
|
||||
@@ -71,7 +68,7 @@ class Json
|
||||
return false;
|
||||
}
|
||||
|
||||
$json = json_decode($json, $assoc, $depth, $options);
|
||||
$json = json_decode($json, $assoc);
|
||||
|
||||
$error = self::getLastError();
|
||||
if ($error) {
|
||||
@@ -117,54 +114,12 @@ class Json
|
||||
return $returns;
|
||||
}
|
||||
|
||||
protected static function getLastError($error = null)
|
||||
protected static function getLastError()
|
||||
{
|
||||
if (!isset($error)) {
|
||||
$error = json_last_error();
|
||||
$error = json_last_error();
|
||||
|
||||
if (!empty($error)) {
|
||||
return json_last_error_msg();
|
||||
}
|
||||
|
||||
switch ($error) {
|
||||
case JSON_ERROR_NONE:
|
||||
return false;
|
||||
break;
|
||||
|
||||
case JSON_ERROR_DEPTH:
|
||||
return 'The maximum stack depth has been exceeded';
|
||||
break;
|
||||
|
||||
case JSON_ERROR_STATE_MISMATCH:
|
||||
return 'Invalid or malformed JSON';
|
||||
break;
|
||||
|
||||
case JSON_ERROR_CTRL_CHAR:
|
||||
return 'Control character error, possibly incorrectly encoded';
|
||||
break;
|
||||
|
||||
case JSON_ERROR_SYNTAX:
|
||||
return 'Syntax error, malformed JSON';
|
||||
break;
|
||||
|
||||
case JSON_ERROR_UTF8:
|
||||
return 'Malformed UTF-8 characters, possibly incorrectly encoded';
|
||||
break;
|
||||
|
||||
/* Only for PHP 5.5.0
|
||||
case JSON_ERROR_RECURSION:
|
||||
return 'One or more recursive references in the value to be encoded';
|
||||
break;
|
||||
case JSON_ERROR_INF_OR_NAN:
|
||||
return 'One or more NAN or INF values in the value to be encoded';
|
||||
break;
|
||||
case JSON_ERROR_UNSUPPORTED_TYPE:
|
||||
return 'A value of a type that cannot be encoded was given';
|
||||
break;
|
||||
*/
|
||||
|
||||
default:
|
||||
return 'Unknown error';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user