From b65bfad44d7758ffabf532b83edbedf34d2ef04a Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 10 Oct 2015 00:40:25 +0300 Subject: [PATCH] Simplified regular expressions --- framework/console/Controller.php | 4 ++-- framework/console/controllers/AssetController.php | 4 ++-- framework/helpers/BaseConsole.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/console/Controller.php b/framework/console/Controller.php index 834a3ffcff..0c8b4da28a 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -363,7 +363,7 @@ class Controller extends \yii\base\Controller foreach ($method->getParameters() as $i => $reflection) { $name = $reflection->getName(); $tag = isset($params[$i]) ? $params[$i] : ''; - if (preg_match('/^([^\s]+)\s+(\$\w+\s+)?(.*)/s', $tag, $matches)) { + if (preg_match('/^(\S+)\s+(\$\w+\s+)?(.*)/s', $tag, $matches)) { $type = $matches[1]; $comment = $matches[3]; } else { @@ -425,7 +425,7 @@ class Controller extends \yii\base\Controller if (is_array($doc)) { $doc = reset($doc); } - if (preg_match('/^([^\s]+)(.*)/s', $doc, $matches)) { + if (preg_match('/^(\S+)(.*)/s', $doc, $matches)) { $type = $matches[1]; $comment = $matches[2]; } else { diff --git a/framework/console/controllers/AssetController.php b/framework/console/controllers/AssetController.php index 1e95a83bde..0eb620a8a1 100644 --- a/framework/console/controllers/AssetController.php +++ b/framework/console/controllers/AssetController.php @@ -617,7 +617,7 @@ EOD; $fullMatch = $matches[0]; $inputUrl = $matches[1]; - if (strpos($inputUrl, '/') === 0 || preg_match('/^https?:\/\//is', $inputUrl) || preg_match('/^data:/is', $inputUrl)) { + if (strpos($inputUrl, '/') === 0 || preg_match('/^https?:\/\//i', $inputUrl) || preg_match('/^data:/i', $inputUrl)) { return $fullMatch; } if ($inputFileRelativePathParts === $outputFileRelativePathParts) { @@ -648,7 +648,7 @@ EOD; return str_replace($inputUrl, $outputUrl, $fullMatch); }; - $cssContent = preg_replace_callback('/url\(["\']?([^)^"^\']*)["\']?\)/is', $callback, $cssContent); + $cssContent = preg_replace_callback('/url\(["\']?([^)^"^\']*)["\']?\)/i', $callback, $cssContent); return $cssContent; } diff --git a/framework/helpers/BaseConsole.php b/framework/helpers/BaseConsole.php index 84a2c22a30..09da45c36a 100644 --- a/framework/helpers/BaseConsole.php +++ b/framework/helpers/BaseConsole.php @@ -613,7 +613,7 @@ class BaseConsole $output = []; exec('mode con', $output); if (isset($output, $output[1]) && strpos($output[1], 'CON') !== false) { - return $size = [(int) preg_replace('~[^0-9]~', '', $output[3]), (int) preg_replace('~[^0-9]~', '', $output[4])]; + return $size = [(int) preg_replace('~\D~', '', $output[3]), (int) preg_replace('~\D~', '', $output[4])]; } } else { // try stty if available