Skip to content
Permalink
Browse files

regexp: \z replaced with D modifier

  • Loading branch information...
dg committed Jul 11, 2019
1 parent 033486c commit e44550d473f8ec49e7f73336b4397e02bb6bb7b3
Showing with 9 additions and 9 deletions.
  1. +1 −1 src/Utils/Html.php
  2. +1 −1 src/Utils/Strings.php
  3. +7 −7 src/Utils/Validators.php
@@ -70,7 +70,7 @@ public static function el(string $name = null, $attrs = null)
}
if (isset($parts[1])) {
foreach (Strings::matchAll($parts[1] . ' ', '#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i') as $m) {
foreach (Strings::matchAll($parts[1] . ' ', '#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\2|\s))?#i') as $m) {
$el->attrs[$m[1]] = $m[3] ?? true;
}
}
@@ -323,7 +323,7 @@ public static function length(string $s): int
public static function trim(string $s, string $charlist = self::TRIM_CHARACTERS): string
{
$charlist = preg_quote($charlist, '#');
return self::replace($s, '#^[' . $charlist . ']+|[' . $charlist . ']+\z#u', '');
return self::replace($s, '#^[' . $charlist . ']+|[' . $charlist . ']+$#Du', '');
}
@@ -144,7 +144,7 @@ public static function is($value, string $expected): bool
continue;
}
} elseif ($type === 'pattern') {
if (preg_match('|^' . ($item[1] ?? '') . '\z|', $value)) {
if (preg_match('|^' . ($item[1] ?? '') . '$|D', $value)) {
return true;
}
continue;
@@ -199,7 +199,7 @@ public static function isNumber($value): bool
*/
public static function isNumericInt($value): bool
{
return is_int($value) || (is_string($value) && preg_match('#^[+-]?[0-9]+\z#', $value));
return is_int($value) || (is_string($value) && preg_match('#^[+-]?[0-9]+$#D', $value));
}
@@ -208,7 +208,7 @@ public static function isNumericInt($value): bool
*/
public static function isNumeric($value): bool
{
return is_float($value) || is_int($value) || (is_string($value) && preg_match('#^[+-]?[0-9]*[.]?[0-9]+\z#', $value));
return is_float($value) || is_int($value) || (is_string($value) && preg_match('#^[+-]?[0-9]*[.]?[0-9]+$#D', $value));
}
@@ -291,7 +291,7 @@ public static function isEmail(string $value): bool
@
([0-9$alpha]([-0-9$alpha]{0,61}[0-9$alpha])?\\.)+ # domain - RFC 1034
[$alpha]([-0-9$alpha]{0,17}[$alpha])? # top domain
\\z)ix", $value);
$)Dix", $value);
}
@@ -310,7 +310,7 @@ public static function isUrl(string $value): bool
|\[[0-9a-f:]{3,39}\] # IPv6
)(:\\d{1,5})? # port
(/\\S*)? # path
\\z)ix", $value);
$)Dix", $value);
}
@@ -319,7 +319,7 @@ public static function isUrl(string $value): bool
*/
public static function isUri(string $value): bool
{
return (bool) preg_match('#^[a-z\d+\.-]+:\S+\z#i', $value);
return (bool) preg_match('#^[a-z\d+\.-]+:\S+$#Di', $value);
}
@@ -337,6 +337,6 @@ public static function isType(string $type): bool
*/
public static function isPhpIdentifier(string $value): bool
{
return is_string($value) && preg_match('#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\z#', $value);
return is_string($value) && preg_match('#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#D', $value);
}
}

0 comments on commit e44550d

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