You are here

protected function ComposerIntegrationTest::getErrorMessages in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::getErrorMessages()

Gets human-readable JSON error messages.

Return value

string[] Keys are JSON_ERROR_* constants.

File

core/tests/Drupal/Tests/ComposerIntegrationTest.php, line 23
Contains \Drupal\Tests\ComposerIntegrationTest.

Class

ComposerIntegrationTest
Tests Composer integration.

Namespace

Drupal\Tests

Code

protected function getErrorMessages() {
  $messages = [
    0 => 'No errors found',
    JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
    JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
    JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
    JSON_ERROR_SYNTAX => 'Syntax error',
    JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded',
  ];
  if (version_compare(phpversion(), '5.5.0', '>=')) {
    $messages[JSON_ERROR_RECURSION] = 'One or more recursive references in the value to be encoded';
    $messages[JSON_ERROR_INF_OR_NAN] = 'One or more NAN or INF values in the value to be encoded';
    $messages[JSON_ERROR_UNSUPPORTED_TYPE] = 'A value of a type that cannot be encoded was given';
  }
  return $messages;
}