Skip to content

Commit 08250b2

Browse files
committed
regexp: \z replaced with D modifier
1 parent d811678 commit 08250b2

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/Application/LinkGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(Router $router, Nette\Http\UrlScript $refUrl, IPrese
4545
*/
4646
public function link(string $dest, array $params = []): string
4747
{
48-
if (!preg_match('~^([\w:]+):(\w*+)(#.*)?()\z~', $dest, $m)) {
48+
if (!preg_match('~^([\w:]+):(\w*+)(#.*)?()$~D', $dest, $m)) {
4949
throw new UI\InvalidLinkException("Invalid link destination '$dest'.");
5050
}
5151
[, $presenter, $action, $frag] = $m;

src/Application/PresenterFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getPresenterClass(string &$name): string
6060
return $this->cache[$name];
6161
}
6262

63-
if (!Nette\Utils\Strings::match($name, '#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*\z#')) {
63+
if (!Nette\Utils\Strings::match($name, '#^[a-zA-Z\x7f-\xff][a-zA-Z0-9\x7f-\xff:]*$#D')) {
6464
throw new InvalidPresenterException("Presenter name must be alphanumeric string, '$name' is invalid.");
6565
}
6666

@@ -97,7 +97,7 @@ public function setMapping(array $mapping)
9797
{
9898
foreach ($mapping as $module => $mask) {
9999
if (is_string($mask)) {
100-
if (!preg_match('#^\\\\?([\w\\\\]*\\\\)?(\w*\*\w*?\\\\)?([\w\\\\]*\*\w*)\z#', $mask, $m)) {
100+
if (!preg_match('#^\\\\?([\w\\\\]*\\\\)?(\w*\*\w*?\\\\)?([\w\\\\]*\*\w*)$#D', $mask, $m)) {
101101
throw new Nette\InvalidStateException("Invalid mapping mask '$mask'.");
102102
}
103103
$this->mapping[$module] = [$m[1], $m[2] ?: '*Module\\', $m[3]];
@@ -137,7 +137,7 @@ public function unformatPresenterClass(string $class): ?string
137137
{
138138
foreach ($this->mapping as $module => $mapping) {
139139
$mapping = str_replace(['\\', '*'], ['\\\\', '(\w+)'], $mapping);
140-
if (preg_match("#^\\\\?$mapping[0]((?:$mapping[1])*)$mapping[2]\\z#i", $class, $matches)) {
140+
if (preg_match("#^\\\\?$mapping[0]((?:$mapping[1])*)$mapping[2]$#Di", $class, $matches)) {
141141
return ($module === '*' ? '' : $module . ':')
142142
. preg_replace("#$mapping[1]#iA", '$1:', $matches[1]) . $matches[3];
143143
}

src/Application/Responses/FileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt
9191

9292
if ($this->resuming) {
9393
$httpResponse->setHeader('Accept-Ranges', 'bytes');
94-
if (preg_match('#^bytes=(\d*)-(\d*)\z#', (string) $httpRequest->getHeader('Range'), $matches)) {
94+
if (preg_match('#^bytes=(\d*)-(\d*)$#D', (string) $httpRequest->getHeader('Range'), $matches)) {
9595
[, $start, $end] = $matches;
9696
if ($start === '') {
9797
$start = max(0, $filesize - $end);

src/Application/UI/ComponentReflection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public static function convertType(&$val, string $type, bool $isClass = false):
207207
} else {
208208
$tmp = ($val === false ? '0' : (string) $val);
209209
if ($type === 'double' || $type === 'float') {
210-
$tmp = preg_replace('#\.0*\z#', '', $tmp);
210+
$tmp = preg_replace('#\.0*$#D', '', $tmp);
211211
}
212212
$orig = $tmp;
213213
settype($tmp, $type);
@@ -226,7 +226,7 @@ public static function convertType(&$val, string $type, bool $isClass = false):
226226
*/
227227
public static function parseAnnotation(\Reflector $ref, string $name): ?array
228228
{
229-
if (!preg_match_all('#[\\s*]@' . preg_quote($name, '#') . '(?:\(\\s*([^)]*)\\s*\)|\\s|$)#', (string) $ref->getDocComment(), $m)) {
229+
if (!preg_match_all('#[\s*]@' . preg_quote($name, '#') . '(?:\(\s*([^)]*)\s*\)|\s|$)#', (string) $ref->getDocComment(), $m)) {
230230
return null;
231231
}
232232
static $tokens = ['true' => true, 'false' => false, 'null' => null];

src/Application/UI/Presenter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ private function initGlobalParameters(): void
11861186
}
11871187

11881188
foreach ($params as $key => $value) {
1189-
if (!preg_match('#^((?:[a-z0-9_]+-)*)((?!\d+\z)[a-z0-9_]+)\z#i', (string) $key, $matches)) {
1189+
if (!preg_match('#^((?:[a-z0-9_]+-)*)((?!\d+$)[a-z0-9_]+)$#Di', (string) $key, $matches)) {
11901190
continue;
11911191
} elseif (!$matches[1]) {
11921192
$selfParams[$key] = $value;
@@ -1197,7 +1197,7 @@ private function initGlobalParameters(): void
11971197

11981198
// init & validate $this->action & $this->view
11991199
$action = $selfParams[self::ACTION_KEY] ?? self::DEFAULT_ACTION;
1200-
if (!is_string($action) || !Nette\Utils\Strings::match($action, '#^[a-zA-Z0-9][a-zA-Z0-9_\x7f-\xff]*\z#')) {
1200+
if (!is_string($action) || !Nette\Utils\Strings::match($action, '#^[a-zA-Z0-9][a-zA-Z0-9_\x7f-\xff]*$#D')) {
12011201
$this->error('Action name is not valid.');
12021202
}
12031203
$this->changeAction($action);

src/Bridges/ApplicationLatte/UIMacros.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function macroControl(MacroNode $node, PhpWriter $writer)
8080
}
8181
$name = $writer->formatWord($words[0]);
8282
$method = ucfirst($words[1] ?? '');
83-
$method = Strings::match($method, '#^\w*\z#') ? "render$method" : "{\"render$method\"}";
83+
$method = Strings::match($method, '#^\w*$#D') ? "render$method" : "{\"render$method\"}";
8484

8585
$tokens = $node->tokenizer;
8686
$pos = $tokens->position;
@@ -113,7 +113,7 @@ public function macroControl(MacroNode $node, PhpWriter $writer)
113113
*/
114114
public function macroLink(MacroNode $node, PhpWriter $writer)
115115
{
116-
$node->modifiers = preg_replace('#\|safeurl\s*(?=\||\z)#i', '', $node->modifiers);
116+
$node->modifiers = preg_replace('#\|safeurl\s*(?=\||$)#Di', '', $node->modifiers);
117117
return $writer->using($node)
118118
->write('echo %escape(%modify('
119119
. ($node->name === 'plink' ? '$this->global->uiPresenter' : '$this->global->uiControl')

0 commit comments

Comments
 (0)