Skip to content
Permalink
Browse files

regexp: \z replaced with D modifier

  • Loading branch information...
dg committed Jul 11, 2019
1 parent 7c7ac13 commit 555fe2bddf0764f78d5fbc050ad8b3860d47b761
@@ -66,10 +66,10 @@ private function setupDatabase(\stdClass $config, string $name): void
$builder = $this->getContainerBuilder();
foreach ($config->options as $key => $value) {
if (is_string($value) && preg_match('#^PDO::\w+\z#', $value)) {
if (is_string($value) && preg_match('#^PDO::\w+$#D', $value)) {
$config->options[$key] = $value = constant($value);
}
if (preg_match('#^PDO::\w+\z#', $key)) {
if (preg_match('#^PDO::\w+$#D', $key)) {
unset($config->options[$key]);
$config->options[constant($key)] = $value;
}
@@ -99,7 +99,7 @@ private function setupDatabase(\stdClass $config, string $name): void
} elseif (is_string($config->conventions)) {
$conventions = $builder->addDefinition($this->prefix("$name.$conventionsServiceName"))
->setFactory(preg_match('#^[a-z]+\z#i', $config->conventions)
->setFactory(preg_match('#^[a-z]+$#Di', $config->conventions)
? 'Nette\Database\Conventions\\' . ucfirst($config->conventions) . 'Conventions'
: $config->conventions)
->setArguments(strtolower($config->conventions) === 'discovered' ? [$structure] : [])
@@ -72,7 +72,7 @@ public function getBelongsToReference(string $table, string $key): ?array
protected function getColumnFromTable(string $name): string
{
if ($this->table !== '%s' && preg_match('(^' . str_replace('%s', '(.*)', preg_quote($this->table)) . '\z)', $name, $match)) {
if ($this->table !== '%s' && preg_match('(^' . str_replace('%s', '(.*)', preg_quote($this->table)) . '$)D', $name, $match)) {
return $match[1];
}
@@ -153,7 +153,7 @@ public function normalizeRow(array $row): array
$row[$key] = new Nette\Utils\DateTime($value);
} elseif ($type === IStructure::FIELD_TIME_INTERVAL) {
preg_match('#^(-?)(\d+)\D(\d+)\D(\d+)(\.\d+)?\z#', $value, $m);
preg_match('#^(-?)(\d+)\D(\d+)\D(\d+)(\.\d+)?$#D', $value, $m);
$row[$key] = new \DateInterval("PT$m[2]H$m[3]M$m[4]S");
$row[$key]->f = isset($m[5]) ? (float) $m[5] : 0.0;
$row[$key]->invert = (int) (bool) $m[1];
@@ -96,7 +96,7 @@ public function process(array $params, bool $useParams = false): array
$this->arrayMode = null;
$res[] = Nette\Utils\Strings::replace(
$param,
'~\'[^\']*+\'|"[^"]*+"|\?[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',
'~\'[^\']*+\'|"[^"]*+"|\?[a-z]*|^\s*+(?:SELECT|INSERT|UPDATE|DELETE|REPLACE|EXPLAIN)\b|\b(?:SET|WHERE|HAVING|ORDER BY|GROUP BY|KEY UPDATE)(?=\s*$|\s*\?)|/\*.*?\*/|--[^\n]*~Dsi',
[$this, 'callback']
);
} else {
@@ -762,7 +762,7 @@ protected function buildQueryEnd(): string
protected function tryDelimite(string $s): string
{
return preg_replace_callback('#(?<=[^\w`"\[?:]|^)[a-z_][a-z0-9_]*(?=[^\w`"(\]]|\z)#i', function (array $m): string {
return preg_replace_callback('#(?<=[^\w`"\[?:]|^)[a-z_][a-z0-9_]*(?=[^\w`"(\]]|$)#Di', function (array $m): string {
return strtoupper($m[0]) === $m[0] ? $m[0] : $this->driver->delimite($m[0]);
}, $s);
}

0 comments on commit 555fe2b

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