Skip to content
Permalink
Browse files

regexp: \z replaced with D modifier

  • Loading branch information...
dg committed Jul 11, 2019
1 parent ecabb3b commit d9c3248886d66710d7115226c721c6012105870e
Showing with 7 additions and 7 deletions.
  1. +5 −5 src/Neon/Decoder.php
  2. +2 −2 src/Neon/Encoder.php
@@ -39,13 +39,13 @@ final class Decoder
'?:[\t\ ]++', // whitespace
];
private const PATTERN_DATETIME = '#\d\d\d\d-\d\d?-\d\d?(?:(?:[Tt]| ++)\d\d?:\d\d:\d\d(?:\.\d*+)? *+(?:Z|[-+]\d\d?(?::?\d\d)?)?)?\z#A';
private const PATTERN_DATETIME = '#\d\d\d\d-\d\d?-\d\d?(?:(?:[Tt]| ++)\d\d?:\d\d:\d\d(?:\.\d*+)? *+(?:Z|[-+]\d\d?(?::?\d\d)?)?)?$#DA';
private const PATTERN_HEX = '#0x[0-9a-fA-F]++\z#A';
private const PATTERN_HEX = '#0x[0-9a-fA-F]++$#DA';
private const PATTERN_OCTAL = '#0o[0-7]++\z#A';
private const PATTERN_OCTAL = '#0o[0-7]++$#DA';
private const PATTERN_BINARY = '#0b[0-1]++\z#A';
private const PATTERN_BINARY = '#0b[0-1]++$#DA';
private const SIMPLE_TYPES = [
'true' => 'TRUE', 'True' => 'TRUE', 'TRUE' => 'TRUE', 'yes' => 'TRUE', 'Yes' => 'TRUE', 'YES' => 'TRUE', 'on' => 'TRUE', 'On' => 'TRUE', 'ON' => 'TRUE',
@@ -256,7 +256,7 @@ private function parse($indent, array $result = null, $key = null, bool $hasKey
if (preg_match('#^...\n++([\t ]*+)#', $t, $m)) {
$converted = substr($t, 3, -3);
$converted = str_replace("\n" . $m[1], "\n", $converted);
$converted = preg_replace('#^\n|\n[\t ]*+\z#', '', $converted);
$converted = preg_replace('#^\n|\n[\t ]*+$#D', '', $converted);
} else {
$converted = substr($t, 1, -1);
}
@@ -68,8 +68,8 @@ public function encode($var, int $flags = 0): string
} elseif (
is_string($var)
&& !is_numeric($var)
&& !preg_match('~[\x00-\x1F]|^\d{4}|^(true|false|yes|no|on|off|null)\z~i', $var)
&& preg_match('~^' . Decoder::PATTERNS[1] . '\z~x', $var) // 1 = literals
&& !preg_match('~[\x00-\x1F]|^\d{4}|^(true|false|yes|no|on|off|null)$~Di', $var)
&& preg_match('~^' . Decoder::PATTERNS[1] . '$~Dx', $var) // 1 = literals
) {
return $var;

0 comments on commit d9c3248

Please sign in to comment.
You can’t perform that action at this time.