Skip to content

Commit

Permalink
regexp: \z replaced with D modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 11, 2019
1 parent aea6e81 commit 45fedc4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/PhpGenerator/Helpers.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static function _dump(&$var, int $level = 0)
return '"' . strtr($var, $table) . '"'; return '"' . strtr($var, $table) . '"';


} elseif (is_string($var)) { } elseif (is_string($var)) {
return "'" . preg_replace('#\'|\\\\(?=[\'\\\\]|\z)#', '\\\\$0', $var) . "'"; return "'" . preg_replace('#\'|\\\\(?=[\'\\\\]|$)#D', '\\\\$0', $var) . "'";
} elseif (is_array($var)) { } elseif (is_array($var)) {
$space = str_repeat("\t", $level); $space = str_repeat("\t", $level);
Expand Down Expand Up @@ -229,13 +229,13 @@ public static function unformatDocComment(string $comment): string


public static function isIdentifier($value): bool public static function isIdentifier($value): bool
{ {
return is_string($value) && preg_match('#^' . self::PHP_IDENT . '\z#', $value); return is_string($value) && preg_match('#^' . self::PHP_IDENT . '$#D', $value);
} }




public static function isNamespaceIdentifier($value, bool $allowLeadingSlash = false): bool public static function isNamespaceIdentifier($value, bool $allowLeadingSlash = false): bool
{ {
$re = '#^' . ($allowLeadingSlash ? '\\\\?' : '') . self::PHP_IDENT . '(\\\\' . self::PHP_IDENT . ')*\z#'; $re = '#^' . ($allowLeadingSlash ? '\\\\?' : '') . self::PHP_IDENT . '(\\\\' . self::PHP_IDENT . ')*$#D';
return is_string($value) && preg_match($re, $value); return is_string($value) && preg_match($re, $value);
} }


Expand Down

0 comments on commit 45fedc4

Please sign in to comment.