Skip to content

Commit 555fe2b

Browse files
committed
regexp: \z replaced with D modifier
1 parent 7c7ac13 commit 555fe2b

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/Bridges/DatabaseDI/DatabaseExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ private function setupDatabase(\stdClass $config, string $name): void
6666
$builder = $this->getContainerBuilder();
6767

6868
foreach ($config->options as $key => $value) {
69-
if (is_string($value) && preg_match('#^PDO::\w+\z#', $value)) {
69+
if (is_string($value) && preg_match('#^PDO::\w+$#D', $value)) {
7070
$config->options[$key] = $value = constant($value);
7171
}
72-
if (preg_match('#^PDO::\w+\z#', $key)) {
72+
if (preg_match('#^PDO::\w+$#D', $key)) {
7373
unset($config->options[$key]);
7474
$config->options[constant($key)] = $value;
7575
}
@@ -99,7 +99,7 @@ private function setupDatabase(\stdClass $config, string $name): void
9999

100100
} elseif (is_string($config->conventions)) {
101101
$conventions = $builder->addDefinition($this->prefix("$name.$conventionsServiceName"))
102-
->setFactory(preg_match('#^[a-z]+\z#i', $config->conventions)
102+
->setFactory(preg_match('#^[a-z]+$#Di', $config->conventions)
103103
? 'Nette\Database\Conventions\\' . ucfirst($config->conventions) . 'Conventions'
104104
: $config->conventions)
105105
->setArguments(strtolower($config->conventions) === 'discovered' ? [$structure] : [])

src/Database/Conventions/StaticConventions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function getBelongsToReference(string $table, string $key): ?array
7272

7373
protected function getColumnFromTable(string $name): string
7474
{
75-
if ($this->table !== '%s' && preg_match('(^' . str_replace('%s', '(.*)', preg_quote($this->table)) . '\z)', $name, $match)) {
75+
if ($this->table !== '%s' && preg_match('(^' . str_replace('%s', '(.*)', preg_quote($this->table)) . '$)D', $name, $match)) {
7676
return $match[1];
7777
}
7878

src/Database/ResultSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function normalizeRow(array $row): array
153153
$row[$key] = new Nette\Utils\DateTime($value);
154154

155155
} elseif ($type === IStructure::FIELD_TIME_INTERVAL) {
156-
preg_match('#^(-?)(\d+)\D(\d+)\D(\d+)(\.\d+)?\z#', $value, $m);
156+
preg_match('#^(-?)(\d+)\D(\d+)\D(\d+)(\.\d+)?$#D', $value, $m);
157157
$row[$key] = new \DateInterval("PT$m[2]H$m[3]M$m[4]S");
158158
$row[$key]->f = isset($m[5]) ? (float) $m[5] : 0.0;
159159
$row[$key]->invert = (int) (bool) $m[1];

src/Database/SqlPreprocessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function process(array $params, bool $useParams = false): array
9696
$this->arrayMode = null;
9797
$res[] = Nette\Utils\Strings::replace(
9898
$param,
99-
'~\'[^\']*+\'|"[^"]*+"|\?[a-z]*|^\s*+(?:SELECT|INSERT|UPDATE|DELETE|REPLACE|EXPLAIN)\b|\b(?:SET|WHERE|HAVING|ORDER BY|GROUP BY|KEY UPDATE)(?=\s*\z|\s*\?)|/\*.*?\*/|--[^\n]*~si',
99+
'~\'[^\']*+\'|"[^"]*+"|\?[a-z]*|^\s*+(?:SELECT|INSERT|UPDATE|DELETE|REPLACE|EXPLAIN)\b|\b(?:SET|WHERE|HAVING|ORDER BY|GROUP BY|KEY UPDATE)(?=\s*$|\s*\?)|/\*.*?\*/|--[^\n]*~Dsi',
100100
[$this, 'callback']
101101
);
102102
} else {

src/Database/Table/SqlBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ protected function buildQueryEnd(): string
762762

763763
protected function tryDelimite(string $s): string
764764
{
765-
return preg_replace_callback('#(?<=[^\w`"\[?:]|^)[a-z_][a-z0-9_]*(?=[^\w`"(\]]|\z)#i', function (array $m): string {
765+
return preg_replace_callback('#(?<=[^\w`"\[?:]|^)[a-z_][a-z0-9_]*(?=[^\w`"(\]]|$)#Di', function (array $m): string {
766766
return strtoupper($m[0]) === $m[0] ? $m[0] : $this->driver->delimite($m[0]);
767767
}, $s);
768768
}

0 commit comments

Comments
 (0)