@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->method = $method; |
| 61 | 61 | $static = $this->isStatic() ? '->' : '::'; |
| 62 | 62 | $name = is_object($object) ? get_class($object) : $object; |
| 63 | - $this->name = $name . $static . $method; |
|
| 63 | + $this->name = $name.$static.$method; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | if (null === $this->requireFile) { |
| 122 | 122 | $this->requireFile = $requireFile; |
| 123 | - $this->name = $this->name . '@' . $requireFile; |
|
| 123 | + $this->name = $this->name.'@'.$requireFile; |
|
| 124 | 124 | } |
| 125 | 125 | return $this; |
| 126 | 126 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | /** |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | // 加载器 |
| 45 | -require_once SUDA_SYSTEM .'/src/framework/loader/Path.php'; |
|
| 46 | -require_once SUDA_SYSTEM .'/src/framework/loader/PathTrait.php'; |
|
| 47 | -require_once SUDA_SYSTEM .'/src/framework/loader/PathInterface.php'; |
|
| 48 | -require_once SUDA_SYSTEM .'/src/framework/loader/IncludeManager.php'; |
|
| 49 | -require_once SUDA_SYSTEM .'/src/framework/loader/Loader.php'; |
|
| 45 | +require_once SUDA_SYSTEM.'/src/framework/loader/Path.php'; |
|
| 46 | +require_once SUDA_SYSTEM.'/src/framework/loader/PathTrait.php'; |
|
| 47 | +require_once SUDA_SYSTEM.'/src/framework/loader/PathInterface.php'; |
|
| 48 | +require_once SUDA_SYSTEM.'/src/framework/loader/IncludeManager.php'; |
|
| 49 | +require_once SUDA_SYSTEM.'/src/framework/loader/Loader.php'; |
|
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | $table = $this->connection->rawTableName($this->name); |
| 106 | 106 | $sql = "CREATE TABLE IF NOT EXISTS `{$table}` (\r\n\t"; |
| 107 | 107 | $sql .= implode(",\r\n\t", array_filter($content, 'strlen')); |
| 108 | - $auto = null === $this->auto?'':'AUTO_INCREMENT='.$this->auto; |
|
| 109 | - $collate = null === $this->collate?'':'COLLATE '.$this->collate; |
|
| 108 | + $auto = null === $this->auto ? '' : 'AUTO_INCREMENT='.$this->auto; |
|
| 109 | + $collate = null === $this->collate ? '' : 'COLLATE '.$this->collate; |
|
| 110 | 110 | $sql .= "\r\n) ENGINE={$this->engine} {$collate} {$auto} DEFAULT CHARSET={$this->charset};"; |
| 111 | 111 | return $sql; |
| 112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | if (count($primary)) { |
| 127 | - return 'PRIMARY KEY ('. implode(',', $primary).')'; |
|
| 127 | + return 'PRIMARY KEY ('.implode(',', $primary).')'; |
|
| 128 | 128 | } |
| 129 | 129 | return ''; |
| 130 | 130 | } |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | protected function createField(Field $field) |
| 218 | 218 | { |
| 219 | 219 | $type = strtoupper($field->getValueType()).$this->parseLength($field->getLength()); |
| 220 | - $auto = $field->getAuto() ?'AUTO_INCREMENT':''; |
|
| 221 | - $null = $field->isNullable() ?'NULL':'NOT NULL'; |
|
| 222 | - $attr = $field->getAttribute() ?strtoupper($field->getAttribute()):''; |
|
| 223 | - $comment = $field->getComment() ?('COMMENT \''.addcslashes($field->getComment(), '\'').'\''):''; |
|
| 220 | + $auto = $field->getAuto() ? 'AUTO_INCREMENT' : ''; |
|
| 221 | + $null = $field->isNullable() ? 'NULL' : 'NOT NULL'; |
|
| 222 | + $attr = $field->getAttribute() ?strtoupper($field->getAttribute()) : ''; |
|
| 223 | + $comment = $field->getComment() ? ('COMMENT \''.addcslashes($field->getComment(), '\'').'\'') : ''; |
|
| 224 | 224 | // default设置 |
| 225 | 225 | if ($field->hasDefault()) { |
| 226 | 226 | if (null === $field->getDefault()) { |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | protected static function fixConfig(Application $application, ?string $module, array $config) |
| 45 | 45 | { |
| 46 | 46 | if (!array_key_exists('assets-prefix', $config)) { |
| 47 | - $config['assets-prefix'] = defined('SUDA_ASSETS') ? constant('SUDA_ASSETS'): 'assets'; |
|
| 47 | + $config['assets-prefix'] = defined('SUDA_ASSETS') ? constant('SUDA_ASSETS') : 'assets'; |
|
| 48 | 48 | } |
| 49 | 49 | if (!array_key_exists('static', $config)) { |
| 50 | 50 | $config['static'] = 'static'; |
| 51 | 51 | } |
| 52 | 52 | if (!array_key_exists('assets-path', $config)) { |
| 53 | - $config['assets-path'] = SUDA_PUBLIC. '/'.$config['assets-prefix']; |
|
| 53 | + $config['assets-path'] = SUDA_PUBLIC.'/'.$config['assets-prefix']; |
|
| 54 | 54 | } |
| 55 | 55 | if (!array_key_exists('static-name', $config)) { |
| 56 | 56 | $config['uri-name'] = static::getSafeUriName($application, $module); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | $assetRoot = static::getAssetRoot($application, $module); |
| 116 | 116 | if (in_array($request->getIndex(), $application->conf('index', ['/index.php']))) { |
| 117 | - $name = static::writableAssets($application, $module) ? dirname($request->getIndex()):$request->getIndex(); |
|
| 117 | + $name = static::writableAssets($application, $module) ? dirname($request->getIndex()) : $request->getIndex(); |
|
| 118 | 118 | return rtrim(str_replace('\\', '/', $name), '/').$assetRoot; |
| 119 | 119 | } |
| 120 | 120 | return rtrim(str_replace('\\', '/', $request->getIndex()), '/').$assetRoot; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | ?string $module = null |
| 151 | 151 | ):string { |
| 152 | 152 | $assetRoot = static::getAssetRoot($application, $module); |
| 153 | - $name = static::writableAssets($application, $module) ? dirname($request->getIndex()):$request->getIndex(); |
|
| 153 | + $name = static::writableAssets($application, $module) ? dirname($request->getIndex()) : $request->getIndex(); |
|
| 154 | 154 | return rtrim(str_replace('\\', '/', $name), '/').$assetRoot; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | if (array_key_exists('server-port', $this->request->server())) { |
| 105 | 105 | return $this->request->server()['server-port']; |
| 106 | 106 | } |
| 107 | - return $this->getSecure()?443:80; |
|
| 107 | + return $this->getSecure() ? 443 : 80; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | private function createUribase(RequestWrapper $request) |
| 150 | 150 | { |
| 151 | - $scheme = $request->isSecure()?'https':'http'; |
|
| 151 | + $scheme = $request->isSecure() ? 'https' : 'http'; |
|
| 152 | 152 | $port = $request->getPort(); |
| 153 | 153 | if ($port == 80 && $scheme == 'http') { |
| 154 | 154 | $port = ''; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } else { |
| 158 | 158 | $port = ':'.$port; |
| 159 | 159 | } |
| 160 | - $base = $scheme.'://'. $request->getHost().$port; |
|
| 160 | + $base = $scheme.'://'.$request->getHost().$port; |
|
| 161 | 161 | $request->setUriBase($base); |
| 162 | 162 | } |
| 163 | 163 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | bool $allowQuery = true, |
| 32 | 32 | ?string $default = null, |
| 33 | 33 | ?string $group = null |
| 34 | - ):?string { |
|
| 34 | + ): ?string { |
|
| 35 | 35 | $group = $group ?? $request->getAttribute('group'); |
| 36 | 36 | $default = $default ?? $request->getAttribute('module'); |
| 37 | 37 | $url = $this->route->create($this->getRouteName($name, $default, $group), $parameter, $allowQuery); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function getUrlIndex(Request $request):string |
| 48 | 48 | { |
| 49 | - $indexArray = $this->conf('index') ?? [ 'index.php' ]; |
|
| 49 | + $indexArray = $this->conf('index') ?? ['index.php']; |
|
| 50 | 50 | $index = ltrim($request->getIndex(), '/'); |
| 51 | 51 | if (!in_array($index, $indexArray)) { |
| 52 | 52 | return $request->getIndex(); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | public function getUriBase(Request $request, bool $beautify = true):string |
| 134 | 134 | { |
| 135 | 135 | $index = $beautify ? $this->getUrlIndex($request) : $request->getIndex(); |
| 136 | - return $request->getUriBase() . $index; |
|
| 136 | + return $request->getUriBase().$index; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -144,6 +144,6 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | protected function getRouteGroupPrefix(?string $group):string |
| 146 | 146 | { |
| 147 | - return $group === null || $group === 'default' ? '': '@'. $group; |
|
| 147 | + return $group === null || $group === 'default' ? '' : '@'.$group; |
|
| 148 | 148 | } |
| 149 | 149 | } |