4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Drush\Internal\Config\Yaml;
14 use Drush\Internal\Config\Yaml\Exception\ParseException;
15 use Drush\Internal\Config\Yaml\Exception\DumpException;
16 use Drush\Internal\Config\Yaml\Tag\TaggedValue;
19 * Inline implements a YAML parser/dumper for the YAML inline syntax.
21 * @author Fabien Potencier <fabien@symfony.com>
27 const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
29 public static $parsedLineNumber;
31 private static $exceptionOnInvalidType = false;
32 private static $objectSupport = false;
33 private static $objectForMap = false;
34 private static $constantSupport = false;
37 * Converts a YAML string to a PHP value.
39 * @param string $value A YAML string
40 * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
41 * @param array $references Mapping of variable names to values
43 * @return mixed A PHP value
45 * @throws ParseException
47 public static function parse($value, $flags = 0, $references = array())
49 if (is_bool($flags)) {
50 @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
53 $flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
59 if (func_num_args() >= 3 && !is_array($references)) {
60 @trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
63 $flags |= Yaml::PARSE_OBJECT;
66 if (func_num_args() >= 4) {
67 @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
69 if (func_get_arg(3)) {
70 $flags |= Yaml::PARSE_OBJECT_FOR_MAP;
74 if (func_num_args() >= 5) {
75 $references = func_get_arg(4);
77 $references = array();
81 self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
82 self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
83 self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
84 self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags);
86 $value = trim($value);
92 if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
93 $mbEncoding = mb_internal_encoding();
94 mb_internal_encoding('ASCII');
98 $tag = self::parseTag($value, $i, $flags);
101 $result = self::parseSequence($value, $flags, $i, $references);
105 $result = self::parseMapping($value, $flags, $i, $references);
109 $result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
113 return new TaggedValue($tag, $result);
116 // some comments are allowed at the end
117 if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
118 throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
121 if (isset($mbEncoding)) {
122 mb_internal_encoding($mbEncoding);
129 * Dumps a given PHP variable to a YAML string.
131 * @param mixed $value The PHP variable to convert
132 * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
134 * @return string The YAML string representing the PHP value
136 * @throws DumpException When trying to dump PHP resource
138 public static function dump($value, $flags = 0)
140 if (is_bool($flags)) {
141 @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
144 $flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE;
150 if (func_num_args() >= 3) {
151 @trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
153 if (func_get_arg(2)) {
154 $flags |= Yaml::DUMP_OBJECT;
159 case is_resource($value):
160 if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
161 throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
165 case $value instanceof \DateTimeInterface:
166 return $value->format('c');
167 case is_object($value):
168 if ($value instanceof TaggedValue) {
169 return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
172 if (Yaml::DUMP_OBJECT & $flags) {
173 return '!php/object:'.serialize($value);
176 if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
177 return self::dumpArray($value, $flags & ~Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
180 if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
181 throw new DumpException('Object support when dumping a YAML file has been disabled.');
185 case is_array($value):
186 return self::dumpArray($value, $flags);
187 case null === $value:
189 case true === $value:
191 case false === $value:
193 case ctype_digit($value):
194 return is_string($value) ? "'$value'" : (int) $value;
195 case is_numeric($value):
196 $locale = setlocale(LC_NUMERIC, 0);
197 if (false !== $locale) {
198 setlocale(LC_NUMERIC, 'C');
200 if (is_float($value)) {
201 $repr = (string) $value;
202 if (is_infinite($value)) {
203 $repr = str_ireplace('INF', '.Inf', $repr);
204 } elseif (floor($value) == $value && $repr == $value) {
205 // Preserve float data type since storing a whole number will result in integer value.
206 $repr = '!!float '.$repr;
209 $repr = is_string($value) ? "'$value'" : (string) $value;
211 if (false !== $locale) {
212 setlocale(LC_NUMERIC, $locale);
218 case self::isBinaryString($value):
219 return '!!binary '.base64_encode($value);
220 case Escaper::requiresDoubleQuoting($value):
221 return Escaper::escapeWithDoubleQuotes($value);
222 case Escaper::requiresSingleQuoting($value):
223 case Parser::preg_match('{^[0-9]+[_0-9]*$}', $value):
224 case Parser::preg_match(self::getHexRegex(), $value):
225 case Parser::preg_match(self::getTimestampRegex(), $value):
226 return Escaper::escapeWithSingleQuotes($value);
233 * Check if given array is hash or just normal indexed array.
237 * @param array|\ArrayObject|\stdClass $value The PHP array or array-like object to check
239 * @return bool true if value is hash array, false otherwise
241 public static function isHash($value)
243 if ($value instanceof \stdClass || $value instanceof \ArrayObject) {
249 foreach ($value as $key => $val) {
250 if ($key !== $expectedKey++) {
259 * Dumps a PHP array to a YAML string.
261 * @param array $value The PHP array to dump
262 * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
264 * @return string The YAML string representing the PHP array
266 private static function dumpArray($value, $flags)
269 if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) {
271 foreach ($value as $val) {
272 $output[] = self::dump($val, $flags);
275 return sprintf('[%s]', implode(', ', $output));
280 foreach ($value as $key => $val) {
281 $output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
284 return sprintf('{ %s }', implode(', ', $output));
288 * Parses a YAML scalar.
290 * @param string $scalar
292 * @param string[] $delimiters
294 * @param bool $evaluate
295 * @param array $references
299 * @throws ParseException When malformed inline YAML string is parsed
303 public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i = 0, $evaluate = true, $references = array(), $legacyOmittedKeySupport = false)
305 if (in_array($scalar[$i], array('"', "'"))) {
307 $output = self::parseQuotedScalar($scalar, $i);
309 if (null !== $delimiters) {
310 $tmp = ltrim(substr($scalar, $i), ' ');
311 if (!in_array($tmp[0], $delimiters)) {
312 throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)));
318 $output = substr($scalar, $i);
319 $i += strlen($output);
322 if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
323 $output = substr($output, 0, $match[0][1]);
325 } elseif (Parser::preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
327 $i += strlen($output);
329 throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar));
332 // a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
333 if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0])) {
334 throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]));
337 if ($output && '%' === $output[0]) {
338 @trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0 on line %d.', $output, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
342 $output = self::evaluateScalar($output, $flags, $references);
350 * Parses a YAML quoted scalar.
352 * @param string $scalar
357 * @throws ParseException When malformed inline YAML string is parsed
359 private static function parseQuotedScalar($scalar, &$i)
361 if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
362 throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)));
365 $output = substr($match[0], 1, strlen($match[0]) - 2);
367 $unescaper = new Unescaper();
368 if ('"' == $scalar[$i]) {
369 $output = $unescaper->unescapeDoubleQuotedString($output);
371 $output = $unescaper->unescapeSingleQuotedString($output);
374 $i += strlen($match[0]);
380 * Parses a YAML sequence.
382 * @param string $sequence
385 * @param array $references
389 * @throws ParseException When malformed inline YAML string is parsed
391 private static function parseSequence($sequence, $flags, &$i = 0, $references = array())
394 $len = strlen($sequence);
399 if (']' === $sequence[$i]) {
402 if (',' === $sequence[$i] || ' ' === $sequence[$i]) {
408 $tag = self::parseTag($sequence, $i, $flags);
409 switch ($sequence[$i]) {
412 $value = self::parseSequence($sequence, $flags, $i, $references);
416 $value = self::parseMapping($sequence, $flags, $i, $references);
419 $isQuoted = in_array($sequence[$i], array('"', "'"));
420 $value = self::parseScalar($sequence, $flags, array(',', ']'), $i, null === $tag, $references);
422 // the value can be an array if a reference has been resolved to an array var
423 if (is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
427 $value = self::parseMapping('{'.$value.'}', $flags, $pos, $references);
428 } catch (\InvalidArgumentException $e) {
437 $value = new TaggedValue($tag, $value);
445 throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence));
449 * Parses a YAML mapping.
451 * @param string $mapping
454 * @param array $references
456 * @return array|\stdClass
458 * @throws ParseException When malformed inline YAML string is parsed
460 private static function parseMapping($mapping, $flags, &$i = 0, $references = array())
463 $len = strlen($mapping);
465 $allowOverwrite = false;
467 // {foo: bar, bar:foo, ...}
469 switch ($mapping[$i]) {
475 if (self::$objectForMap) {
476 return (object) $output;
483 $isKeyQuoted = in_array($mapping[$i], array('"', "'"), true);
484 $key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false, array(), true);
486 if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
491 @trigger_error(sprintf('Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0 on line %d.', self::$parsedLineNumber + 1), E_USER_DEPRECATED);
494 if (!(Yaml::PARSE_KEYS_AS_STRINGS & $flags)) {
495 $evaluatedKey = self::evaluateScalar($key, $flags, $references);
497 if ('' !== $key && $evaluatedKey !== $key && !is_string($evaluatedKey) && !is_int($evaluatedKey)) {
498 @trigger_error(sprintf('Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line %d.', self::$parsedLineNumber + 1), E_USER_DEPRECATED);
502 if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
503 @trigger_error(sprintf('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since version 3.2 and will throw a ParseException in 4.0 on line %d.', self::$parsedLineNumber + 1), E_USER_DEPRECATED);
507 $allowOverwrite = true;
511 if (':' === $mapping[$i] || ' ' === $mapping[$i]) {
517 $tag = self::parseTag($mapping, $i, $flags);
518 switch ($mapping[$i]) {
521 $value = self::parseSequence($mapping, $flags, $i, $references);
522 // Spec: Keys MUST be unique; first one wins.
523 // Parser cannot abort this mapping earlier, since lines
524 // are processed sequentially.
525 // But overwriting is allowed when a merge node is used in current block.
527 foreach ($value as $parsedValue) {
528 $output += $parsedValue;
530 } elseif ($allowOverwrite || !isset($output[$key])) {
532 $output[$key] = new TaggedValue($tag, $value);
534 $output[$key] = $value;
536 } elseif (isset($output[$key])) {
537 @trigger_error(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line %d.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
542 $value = self::parseMapping($mapping, $flags, $i, $references);
543 // Spec: Keys MUST be unique; first one wins.
544 // Parser cannot abort this mapping earlier, since lines
545 // are processed sequentially.
546 // But overwriting is allowed when a merge node is used in current block.
549 } elseif ($allowOverwrite || !isset($output[$key])) {
551 $output[$key] = new TaggedValue($tag, $value);
553 $output[$key] = $value;
555 } elseif (isset($output[$key])) {
556 @trigger_error(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line %d.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
560 $value = self::parseScalar($mapping, $flags, array(',', '}'), $i, null === $tag, $references);
561 // Spec: Keys MUST be unique; first one wins.
562 // Parser cannot abort this mapping earlier, since lines
563 // are processed sequentially.
564 // But overwriting is allowed when a merge node is used in current block.
567 } elseif ($allowOverwrite || !isset($output[$key])) {
569 $output[$key] = new TaggedValue($tag, $value);
571 $output[$key] = $value;
573 } elseif (isset($output[$key])) {
574 @trigger_error(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line %d.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
584 throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping));
588 * Evaluates scalars and replaces magic values.
590 * @param string $scalar
592 * @param array $references
594 * @return mixed The evaluated YAML string
596 * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
598 private static function evaluateScalar($scalar, $flags, $references = array())
600 $scalar = trim($scalar);
601 $scalarLower = strtolower($scalar);
603 if (0 === strpos($scalar, '*')) {
604 if (false !== $pos = strpos($scalar, '#')) {
605 $value = substr($scalar, 1, $pos - 2);
607 $value = substr($scalar, 1);
611 if (false === $value || '' === $value) {
612 throw new ParseException('A reference must contain at least one character.');
615 if (!array_key_exists($value, $references)) {
616 throw new ParseException(sprintf('Reference "%s" does not exist.', $value));
619 return $references[$value];
623 case 'null' === $scalarLower:
625 case '~' === $scalar:
627 case 'true' === $scalarLower:
629 case 'false' === $scalarLower:
631 case '!' === $scalar[0]:
633 case 0 === strpos($scalar, '!str'):
634 return (string) substr($scalar, 5);
635 case 0 === strpos($scalar, '! '):
636 return (int) self::parseScalar(substr($scalar, 2), $flags);
637 case 0 === strpos($scalar, '!php/object:'):
638 if (self::$objectSupport) {
639 return unserialize(substr($scalar, 12));
642 if (self::$exceptionOnInvalidType) {
643 throw new ParseException('Object support when parsing a YAML file has been disabled.');
647 case 0 === strpos($scalar, '!!php/object:'):
648 if (self::$objectSupport) {
649 @trigger_error(sprintf('The !!php/object tag to indicate dumped PHP objects is deprecated since version 3.1 and will be removed in 4.0. Use the !php/object tag instead on line %d.', self::$parsedLineNumber + 1), E_USER_DEPRECATED);
651 return unserialize(substr($scalar, 13));
654 if (self::$exceptionOnInvalidType) {
655 throw new ParseException('Object support when parsing a YAML file has been disabled.');
659 case 0 === strpos($scalar, '!php/const:'):
660 if (self::$constantSupport) {
661 if (defined($const = substr($scalar, 11))) {
662 return constant($const);
665 throw new ParseException(sprintf('The constant "%s" is not defined.', $const));
667 if (self::$exceptionOnInvalidType) {
668 throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar));
672 case 0 === strpos($scalar, '!!float '):
673 return (float) substr($scalar, 8);
674 case 0 === strpos($scalar, '!!binary '):
675 return self::evaluateBinaryScalar(substr($scalar, 9));
677 @trigger_error(sprintf('Using the unquoted scalar value "%s" is deprecated since version 3.3 and will be considered as a tagged value in 4.0. You must quote it on line %d.', $scalar, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
680 // Optimize for returning strings.
682 case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]):
684 case Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar):
685 $scalar = str_replace('_', '', (string) $scalar);
686 // omitting the break / return as integers are handled in the next case
688 case ctype_digit($scalar):
690 $cast = (int) $scalar;
692 return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
693 case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
695 $cast = (int) $scalar;
697 return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
698 case is_numeric($scalar):
699 case Parser::preg_match(self::getHexRegex(), $scalar):
700 $scalar = str_replace('_', '', $scalar);
702 return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
703 case '.inf' === $scalarLower:
704 case '.nan' === $scalarLower:
706 case '-.inf' === $scalarLower:
708 case Parser::preg_match('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar):
709 case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
710 if (false !== strpos($scalar, ',')) {
711 @trigger_error(sprintf('Using the comma as a group separator for floats is deprecated since version 3.2 and will be removed in 4.0 on line %d.', self::$parsedLineNumber + 1), E_USER_DEPRECATED);
714 return (float) str_replace(array(',', '_'), '', $scalar);
715 case Parser::preg_match(self::getTimestampRegex(), $scalar):
716 if (Yaml::PARSE_DATETIME & $flags) {
717 // When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
718 return new \DateTime($scalar, new \DateTimeZone('UTC'));
721 $timeZone = date_default_timezone_get();
722 date_default_timezone_set('UTC');
723 $time = strtotime($scalar);
724 date_default_timezone_set($timeZone);
730 return (string) $scalar;
734 * @param string $value
738 * @return null|string
740 private static function parseTag($value, &$i, $flags)
742 if ('!' !== $value[$i]) {
746 $tagLength = strcspn($value, " \t\n", $i + 1);
747 $tag = substr($value, $i + 1, $tagLength);
749 $nextOffset = $i + $tagLength + 1;
750 $nextOffset += strspn($value, ' ', $nextOffset);
752 // Is followed by a scalar
753 if (!isset($value[$nextOffset]) || !in_array($value[$nextOffset], array('[', '{'), true)) {
754 // Manage scalars in {@link self::evaluateScalar()}
759 if ($tag && '!' === $tag[0]) {
760 throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag));
763 if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
769 throw new ParseException(sprintf('Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!%s".', $tag));
773 * @param string $scalar
779 public static function evaluateBinaryScalar($scalar)
781 $parsedBinaryData = self::parseScalar(preg_replace('/\s/', '', $scalar));
783 if (0 !== (strlen($parsedBinaryData) % 4)) {
784 throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', strlen($parsedBinaryData)));
787 if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) {
788 throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData));
791 return base64_decode($parsedBinaryData, true);
794 private static function isBinaryString($value)
796 return !preg_match('//u', $value) || preg_match('/[^\x00\x07-\x0d\x1B\x20-\xff]/', $value);
800 * Gets a regex that matches a YAML date.
802 * @return string The regular expression
804 * @see http://www.yaml.org/spec/1.2/spec.html#id2761573
806 private static function getTimestampRegex()
810 (?P<year>[0-9][0-9][0-9][0-9])
811 -(?P<month>[0-9][0-9]?)
812 -(?P<day>[0-9][0-9]?)
814 (?P<hour>[0-9][0-9]?)
815 :(?P<minute>[0-9][0-9])
816 :(?P<second>[0-9][0-9])
817 (?:\.(?P<fraction>[0-9]*))?
818 (?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
819 (?::(?P<tz_minute>[0-9][0-9]))?))?)?
825 * Gets a regex that matches a YAML number in hexadecimal notation.
829 private static function getHexRegex()
831 return '~^0x[0-9a-f_]++$~i';