handleJsonError() private static method

Helper method to create a JSON error.
private static handleJsonError ( integer $errno ) : void
$errno integer An error number from json_last_error()
return void
Exemplo n.º 1
0
 /**
  * Encode a PHP object into a JSON string.
  *
  * @param object|array $input A PHP object or array
  *
  * @return string          JSON representation of the PHP object or array
  * @throws DomainException Provided object could not be encoded to valid JSON
  */
 public static function jsonEncode($input)
 {
     $json = json_encode($input);
     if (function_exists('json_last_error') && ($errno = json_last_error())) {
         JWT::handleJsonError($errno);
     } elseif ($json === 'null' && $input !== null) {
         throw new DomainException('Null result with non-null input');
     }
     return $json;
 }
Exemplo n.º 2
0
 /**
  * Encode a PHP object into a JSON string.
  *
  * @param object|array $input A PHP object or array
  *
  * @return string          JSON representation of the PHP object or array
  * @throws DomainException Provided object could not be encoded to valid JSON
  */
 public static function jsonEncode($input)
 {
     $json = json_encode($input);
     if (function_exists('json_last_error') && ($errno = json_last_error())) {
         JWT::handleJsonError($errno);
     } elseif ($json === 'null' && $input !== null) {
         return null;
     }
     return $json;
 }