@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param string $filename |
| 62 | 62 | * @return string|null |
| 63 | 63 | */ |
| 64 | - public static function get(string $filename):?string; |
|
| 64 | + public static function get(string $filename): ?string; |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param int $mode |
| 85 | 85 | * @return Iterator |
| 86 | 86 | */ |
| 87 | - public static function readFiles(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : Iterator; |
|
| 87 | + public static function readFiles(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : Iterator; |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * 读目录下文件夹 |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param int $mode |
| 97 | 97 | * @return Iterator |
| 98 | 98 | */ |
| 99 | - public static function readDirs(string $path, bool $recursive=false, ?string $regex=null, bool $full=false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 99 | + public static function readDirs(string $path, bool $recursive = false, ?string $regex = null, bool $full = false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * 读目录,包括文件,文件夹 |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param int $mode |
| 109 | 109 | * @return Iterator |
| 110 | 110 | */ |
| 111 | - public static function read(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 111 | + public static function read(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * 截断部分目录 |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param boolean $move |
| 129 | 129 | * @return boolean |
| 130 | 130 | */ |
| 131 | - public static function copyDir(string $path, string $toPath, ?string $regex=null, bool $move = false):bool; |
|
| 131 | + public static function copyDir(string $path, string $toPath, ?string $regex = null, bool $move = false):bool; |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * 移动文件夹 |
@@ -138,5 +138,5 @@ discard block |
||
| 138 | 138 | * @param string|null $regex |
| 139 | 139 | * @return boolean |
| 140 | 140 | */ |
| 141 | - public static function moveDir(string $path, string $toPath, ?string $regex=null):bool; |
|
| 141 | + public static function moveDir(string $path, string $toPath, ?string $regex = null):bool; |
|
| 142 | 142 | } |
@@ -91,18 +91,18 @@ |
||
| 91 | 91 | */ |
| 92 | 92 | public static function createDefaultLogger(): LoggerInterface |
| 93 | 93 | { |
| 94 | - $dataPath = SUDA_DATA . '/logs'; |
|
| 94 | + $dataPath = SUDA_DATA.'/logs'; |
|
| 95 | 95 | FileSystem::make($dataPath); |
| 96 | 96 | if (is_writable(dirname($dataPath))) { |
| 97 | - FileSystem::make($dataPath . '/zip'); |
|
| 98 | - FileSystem::make($dataPath . '/dump'); |
|
| 97 | + FileSystem::make($dataPath.'/zip'); |
|
| 98 | + FileSystem::make($dataPath.'/dump'); |
|
| 99 | 99 | return new FileLogger( |
| 100 | 100 | [ |
| 101 | 101 | 'log-level' => SUDA_DEBUG_LEVEL, |
| 102 | 102 | 'save-path' => $dataPath, |
| 103 | - 'save-zip-path' => $dataPath . '/zip', |
|
| 103 | + 'save-zip-path' => $dataPath.'/zip', |
|
| 104 | 104 | 'log-format' => '%message%', |
| 105 | - 'save-pack-path' => $dataPath . '/dump', |
|
| 105 | + 'save-pack-path' => $dataPath.'/dump', |
|
| 106 | 106 | ] |
| 107 | 107 | ); |
| 108 | 108 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | // 添加 * ? 匹配 |
| 37 | 37 | $url = str_replace(['\*', '\?'], ['[^/]*?', '[^/]'], $url); |
| 38 | 38 | // 编译页面参数 |
| 39 | - $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function ($match) use (&$parameters) { |
|
| 39 | + $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function($match) use (&$parameters) { |
|
| 40 | 40 | $name = $match[1]; |
| 41 | 41 | $type = 'string'; |
| 42 | 42 | $extra = ''; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $url = static::parseIgnorableParameter($url, $matcher, $parameter, $mapper); |
| 71 | 71 | $url = static::replaceParameter($url, $matcher, $parameter, $mapper); |
| 72 | 72 | if (count($query) && $allowQuery) { |
| 73 | - return $url . '?' . http_build_query($query, 'v', '&', PHP_QUERY_RFC3986); |
|
| 73 | + return $url.'?'.http_build_query($query, 'v', '&', PHP_QUERY_RFC3986); |
|
| 74 | 74 | } |
| 75 | 75 | return $url; |
| 76 | 76 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | array $parameter, |
| 89 | 89 | array $mapper |
| 90 | 90 | ): string { |
| 91 | - return preg_replace_callback('/\[(.+?)\]/', function ($match) use ($matcher, $parameter, $mapper) { |
|
| 91 | + return preg_replace_callback('/\[(.+?)\]/', function($match) use ($matcher, $parameter, $mapper) { |
|
| 92 | 92 | if (preg_match('/\{(\w+).+?\}/', $match[1])) { |
| 93 | 93 | $count = 0; |
| 94 | 94 | $subUrl = static::replaceParameter($match[1], $matcher, $parameter, $mapper, true, $count); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | ) { |
| 142 | 142 | return preg_replace_callback( |
| 143 | 143 | '/\{(\w+).+?\}/', |
| 144 | - function ($match) use ($matcher, $parameter, $mapper, $ignore, &$count) { |
|
| 144 | + function($match) use ($matcher, $parameter, $mapper, $ignore, &$count) { |
|
| 145 | 145 | if (array_key_exists($match[1], $mapper)) { |
| 146 | 146 | $count++; |
| 147 | 147 | return $mapper[$match[1]]->packValue($parameter[$match[1]]); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | foreach ($this->application->getModules() as $name => $module) { |
| 54 | 54 | if ($module->getStatus() === Module::REACHABLE) { |
| 55 | - call_user_func([$this->moduleLoader[$name],'toReachable']); |
|
| 55 | + call_user_func([$this->moduleLoader[$name], 'toReachable']); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function getDataSourceGroup(string $groupName):DataSource |
| 95 | 95 | { |
| 96 | - $group = $groupName === 'default' ? '': '-'. $groupName; |
|
| 96 | + $group = $groupName === 'default' ? '' : '-'.$groupName; |
|
| 97 | 97 | $dataSourceConfigPath = $this->application->getResource()->getConfigResourcePath('config/data-source'.$group); |
| 98 | 98 | $dataSource = new DataSource; |
| 99 | 99 | $observer = new DebugObserver($this->application->debug()); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | protected function registerModule() |
| 160 | 160 | { |
| 161 | - $extractPath = SUDA_DATA .'/extract-module'; |
|
| 161 | + $extractPath = SUDA_DATA.'/extract-module'; |
|
| 162 | 162 | FileSystem::make($extractPath); |
| 163 | 163 | foreach ($this->application->getModulePaths() as $path) { |
| 164 | 164 | $this->registerModuleFrom($path, $extractPath); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | public function __construct(string $name, int $type = 0) |
| 14 | 14 | { |
| 15 | 15 | $this->name = $name; |
| 16 | - parent::__construct(sprintf('missing %s template %s', $type == 0 ? 'source':'dest', $name)); |
|
| 16 | + parent::__construct(sprintf('missing %s template %s', $type == 0 ? 'source' : 'dest', $name)); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | // 任意变量名: 中文点下划线英文数字 |
| 16 | 16 | $code = preg_replace_callback( |
| 17 | 17 | '/\B[$](\?)?[:]([.\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )?/ux', |
| 18 | - [$this,'echoValueCallback'], |
|
| 18 | + [$this, 'echoValueCallback'], |
|
| 19 | 19 | $var |
| 20 | 20 | ); |
| 21 | 21 | $error = preg_last_error(); |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | protected function echoValueCallback($matchs) |
| 29 | 29 | { |
| 30 | - $name=$matchs[2]; |
|
| 31 | - if ($matchs[1]==='?') { |
|
| 30 | + $name = $matchs[2]; |
|
| 31 | + if ($matchs[1] === '?') { |
|
| 32 | 32 | return '$this->has("'.$name.'")'; |
| 33 | 33 | } |
| 34 | 34 | if (isset($matchs[4])) { |
| 35 | 35 | if (preg_match('/\((.+)\)/', $matchs[4], $v)) { |
| 36 | 36 | $args = trim($v[1]); |
| 37 | - $args= strlen($args) ?','.$args:''; |
|
| 37 | + $args = strlen($args) ? ','.$args : ''; |
|
| 38 | 38 | return '$this->get("'.$name.'"'.$args.')'; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -26,14 +26,14 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @var Tag[] |
| 28 | 28 | */ |
| 29 | - protected $tags=[]; |
|
| 29 | + protected $tags = []; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * 命令对象 |
| 33 | 33 | * |
| 34 | 34 | * @var CommandInterface[] |
| 35 | 35 | */ |
| 36 | - protected $commands=[]; |
|
| 36 | + protected $commands = []; |
|
| 37 | 37 | |
| 38 | 38 | public function __construct() |
| 39 | 39 | { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function registerTag(Tag $tag) |
| 64 | 64 | { |
| 65 | - $this->tags[$tag->getName()] =$tag; |
|
| 65 | + $this->tags[$tag->getName()] = $tag; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | public function compileText(string $text, array $tagConfig = []):string |
| 77 | 77 | { |
| 78 | 78 | $this->applyTagConfig($tagConfig); |
| 79 | - $result = ''; |
|
| 79 | + $result = ''; |
|
| 80 | 80 | foreach (token_get_all($text) as $token) { |
| 81 | 81 | if (is_array($token)) { |
| 82 | 82 | list($tag, $content) = $token; |
| 83 | 83 | // 所有将要编译的文本 |
| 84 | 84 | // 跳过各种的PHP |
| 85 | 85 | if ($tag == T_INLINE_HTML) { |
| 86 | - $content=$this->proccesTags($content); |
|
| 87 | - $content=$this->processCommands($content); |
|
| 86 | + $content = $this->proccesTags($content); |
|
| 87 | + $content = $this->processCommands($content); |
|
| 88 | 88 | } |
| 89 | 89 | $result .= $content; |
| 90 | 90 | } else { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | foreach ($this->tags as $tag) { |
| 110 | 110 | $pregExp = sprintf('/(!)?%s\s*(.+?)\s*%s/', preg_quote($tag->getOpen()), preg_quote($tag->getClose())); |
| 111 | - $text = preg_replace_callback($pregExp, function ($match) use ($tag) { |
|
| 111 | + $text = preg_replace_callback($pregExp, function($match) use ($tag) { |
|
| 112 | 112 | if ($match[1] === '!') { |
| 113 | 113 | return substr($match[0], 1); |
| 114 | 114 | } else { |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function processCommands(string $text):string |
| 128 | 128 | { |
| 129 | - $pregExp ='/\B\@(\!)?([\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )? /ux'; |
|
| 130 | - $code = preg_replace_callback($pregExp, [$this,'doMatchCommand'], $text); |
|
| 129 | + $pregExp = '/\B\@(\!)?([\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )? /ux'; |
|
| 130 | + $code = preg_replace_callback($pregExp, [$this, 'doMatchCommand'], $text); |
|
| 131 | 131 | $error = preg_last_error(); |
| 132 | 132 | if ($error !== PREG_NO_ERROR) { |
| 133 | 133 | throw new Exception($error); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | list($input, $ignore, $name, $space) = $match; |
| 144 | 144 | $params = ''; |
| 145 | 145 | } |
| 146 | - if ($ignore ==='!') { |
|
| 146 | + if ($ignore === '!') { |
|
| 147 | 147 | return str_replace('@!', '@', $input); |
| 148 | 148 | } else { |
| 149 | 149 | foreach ($this->commands as $command) { |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | $this->content = $content; |
| 41 | 41 | $this->name = $name; |
| 42 | 42 | $this->open = $open; |
| 43 | - $this->close= $close; |
|
| 43 | + $this->close = $close; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param string $path |
| 80 | 80 | * @return Module|null |
| 81 | 81 | */ |
| 82 | - public function guess(string $path):?Module |
|
| 82 | + public function guess(string $path): ?Module |
|
| 83 | 83 | { |
| 84 | 84 | foreach ($this->module as $module) { |
| 85 | 85 | if (FileSystem::isOverflowPath($module->getPath(), $path) === false) { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @throws ApplicationException |
| 112 | 112 | * @return Module|null |
| 113 | 113 | */ |
| 114 | - public function get(string $name):?Module |
|
| 114 | + public function get(string $name): ?Module |
|
| 115 | 115 | { |
| 116 | 116 | $full = $this->getFullName($name); |
| 117 | 117 | return $this->module[$full]; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | if (array_key_exists($version, $this->knownsFullName[$name])) { |
| 196 | 196 | return $this->knownsFullName[$name][$version]; |
| 197 | 197 | } |
| 198 | - return $hasVersion?$name.':'.$version:end($this->knownsFullName[$name]); |
|
| 198 | + return $hasVersion ? $name.':'.$version : end($this->knownsFullName[$name]); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | protected function getLikeName(string $name):string |