You are here

public static function Parser::preg_match in Lockr 7.3

A local wrapper for `preg_match` which will throw a ParseException if there is an internal error in the PCRE engine.

This avoids us needing to check for "false" every time PCRE is used in the YAML engine

@internal

Throws

ParseException on a PCRE internal error

See also

preg_last_error()

9 calls to Parser::preg_match()
Inline::dump in vendor/symfony/yaml/Inline.php
Dumps a given PHP variable to a YAML string.
Inline::evaluateBinaryScalar in vendor/symfony/yaml/Inline.php
@internal
Inline::evaluateScalar in vendor/symfony/yaml/Inline.php
Evaluates scalars and replaces magic values.
Inline::parseQuotedScalar in vendor/symfony/yaml/Inline.php
Parses a YAML quoted scalar.
Inline::parseScalar in vendor/symfony/yaml/Inline.php
Parses a YAML scalar.

... See full list

File

vendor/symfony/yaml/Parser.php, line 1058

Class

Parser
Parser parses YAML strings to convert them to PHP arrays.

Namespace

Symfony\Component\Yaml

Code

public static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0) {
  if (false === ($ret = preg_match($pattern, $subject, $matches, $flags, $offset))) {
    switch (preg_last_error()) {
      case PREG_INTERNAL_ERROR:
        $error = 'Internal PCRE error.';
        break;
      case PREG_BACKTRACK_LIMIT_ERROR:
        $error = 'pcre.backtrack_limit reached.';
        break;
      case PREG_RECURSION_LIMIT_ERROR:
        $error = 'pcre.recursion_limit reached.';
        break;
      case PREG_BAD_UTF8_ERROR:
        $error = 'Malformed UTF-8 data.';
        break;
      case PREG_BAD_UTF8_OFFSET_ERROR:
        $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
        break;
      default:
        $error = 'Error.';
    }
    throw new ParseException($error);
  }
  return $ret;
}