Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. IsJson.php

function IsJson::determineJsonError

1 call to IsJson::determineJsonError()
IsJson::failureDescription in vendor/phpunit/phpunit/src/Framework/Constraint/String/IsJson.php
Returns the description of the failure.

File

vendor/phpunit/phpunit/src/Framework/Constraint/String/IsJson.php, line 77

Class

IsJson
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Framework\Constraint

Code

private function determineJsonError(string $json) : string {
    json_decode($json);
    return match (json_last_error()) {    JSON_ERROR_NONE => '',
        JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
        JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch',
        JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
        JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
        JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded',
        default => 'Unknown error',
    
    };
}
RSS feed
Powered by Drupal