@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public function __construct($file) |
| 39 | 39 | { |
| 40 | - $this->file = $file instanceof SplFileObject? $file : new SplFileObject($file); |
|
| 40 | + $this->file = $file instanceof SplFileObject ? $file : new SplFileObject($file); |
|
| 41 | 41 | $this->mime = MimeType::getMimeType($this->file->getExtension()); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | protected function sendMultipleRangePart(Response $response, array $range) |
| 130 | 130 | { |
| 131 | 131 | $response->write('Content-Type: '.$this->mime."\r\n"); |
| 132 | - $response->write('Content-Range: '.$this->getRangeHeader($range) ."\r\n\r\n"); |
|
| 132 | + $response->write('Content-Range: '.$this->getRangeHeader($range)."\r\n\r\n"); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @param string $range |
| 189 | 189 | * @return array |
| 190 | 190 | */ |
| 191 | - protected function parseRange(string $range):?array |
|
| 191 | + protected function parseRange(string $range): ?array |
|
| 192 | 192 | { |
| 193 | 193 | $range = trim($range); |
| 194 | 194 | if (strrpos($range, '-') === strlen($range) - 1) { |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | list($start, $end) = explode('-', $range, 2); |
| 201 | 201 | $length = intval($end - $start); |
| 202 | 202 | if ($length <= 0) { |
| 203 | - return ['start' => intval($start) , 'end' => $this->file->getSize() - 1 ]; |
|
| 203 | + return ['start' => intval($start), 'end' => $this->file->getSize() - 1]; |
|
| 204 | 204 | } |
| 205 | - return ['start' => intval($start) , 'end' => intval($end) ]; |
|
| 205 | + return ['start' => intval($start), 'end' => intval($end)]; |
|
| 206 | 206 | } |
| 207 | 207 | return null; |
| 208 | 208 | } |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | * @return DataAccess |
| 60 | 60 | * @throws ReflectionException |
| 61 | 61 | */ |
| 62 | - public static function new(string $object, ?Middleware $middleware = null):DataAccess |
|
| 62 | + public static function new(string $object, ?Middleware $middleware = null) : DataAccess |
|
| 63 | 63 | { |
| 64 | 64 | return new self($object, $middleware); |
| 65 | 65 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | protected function getStaticOutpath() |
| 111 | 111 | { |
| 112 | - $path = $this->config['assets-public'] ?? constant('SUDA_PUBLIC').'/assets/'. $this->getStaticName(); |
|
| 112 | + $path = $this->config['assets-public'] ?? constant('SUDA_PUBLIC').'/assets/'.$this->getStaticName(); |
|
| 113 | 113 | FileSystem::make($path); |
| 114 | 114 | return $path; |
| 115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | { |
| 124 | 124 | $output = $this->config['output'] ?? constant('SUDA_DATA').'/template'; |
| 125 | 125 | FileSystem::make($output); |
| 126 | - return $output .'/'. $this->name.'-'.substr(md5_file($this->getSourcePath()), 10, 8).'.php'; |
|
| 126 | + return $output.'/'.$this->name.'-'.substr(md5_file($this->getSourcePath()), 10, 8).'.php'; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @return string|null |
| 133 | 133 | */ |
| 134 | - public function getSourcePath():?string |
|
| 134 | + public function getSourcePath(): ?string |
|
| 135 | 135 | { |
| 136 | 136 | return $this->source ?? null; |
| 137 | 137 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return void |
| 154 | 154 | */ |
| 155 | - protected function compile(){ |
|
| 155 | + protected function compile() { |
|
| 156 | 156 | $sourcePath = $this->getSourcePath(); |
| 157 | 157 | $destPath = $this->getPath(); |
| 158 | 158 | if ($sourcePath === null) { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | public function include(string $path) |
| 206 | 206 | { |
| 207 | 207 | $subfix = $this->config['subfix'] ?? ''; |
| 208 | - $included = new self(Resource::getPathByRelativePath($path. $subfix, dirname($this->source)), $this->config); |
|
| 208 | + $included = new self(Resource::getPathByRelativePath($path.$subfix, dirname($this->source)), $this->config); |
|
| 209 | 209 | $included->parent = $this; |
| 210 | 210 | echo $included->getRenderedString(); |
| 211 | 211 | } |
@@ -222,13 +222,13 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $this->prepareStaticSource(); |
| 224 | 224 | if (array_key_exists('assets-prefix', $this->config)) { |
| 225 | - $prefix = $this->config['assets-prefix'] ; |
|
| 225 | + $prefix = $this->config['assets-prefix']; |
|
| 226 | 226 | } elseif (defined('SUDA_ASSETS')) { |
| 227 | 227 | $prefix = constant('SUDA_ASSETS'); |
| 228 | 228 | } else { |
| 229 | 229 | $prefix = '/assets'; |
| 230 | 230 | } |
| 231 | - return $prefix .'/'.$this->getStaticName(); |
|
| 231 | + return $prefix.'/'.$this->getStaticName(); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | protected function prepareStaticSource() |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return string|null |
| 31 | 31 | */ |
| 32 | - public function getSourcePath():?string |
|
| 32 | + public function getSourcePath(): ?string |
|
| 33 | 33 | { |
| 34 | 34 | $subfix = $this->config['subfix'] ?? '.tpl.html'; |
| 35 | 35 | return $this->getResource($this->module)->getResourcePath($this->getTemplatePath().'/'.$this->name.$subfix); |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function getPath() |
| 44 | 44 | { |
| 45 | - $output = $this->config['output'] ?? constant('SUDA_DATA').'/template/'. $this->uriName; |
|
| 45 | + $output = $this->config['output'] ?? constant('SUDA_DATA').'/template/'.$this->uriName; |
|
| 46 | 46 | FileSystem::make($output); |
| 47 | - return $output .'/'. $this->name.'.php'; |
|
| 47 | + return $output.'/'.$this->name.'.php'; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | return $this->application->getUrl($this->request, $name, $values ?? [], true, $this->module, $this->group); |
| 74 | 74 | } elseif (is_array($name) && is_string($defaultName)) { |
| 75 | - return $this->application->getUrl($this->request, $defaultName, array_merge($this->request->get() ?? [], $name) , true, $this->module, $this->group); |
|
| 75 | + return $this->application->getUrl($this->request, $defaultName, array_merge($this->request->get() ?? [], $name), true, $this->module, $this->group); |
|
| 76 | 76 | } elseif (is_string($defaultName)) { |
| 77 | 77 | return $this->application->getUrl($this->request, $defaultName, $this->request->get() ?? [], true, $this->module, $this->group); |
| 78 | 78 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | if ($this->request->getAttribute('route') === $full) { |
| 92 | 92 | if (is_array($parameter)) { |
| 93 | 93 | foreach ($parameter as $key => $value) { |
| 94 | - if ($this->request->getQuery($key) != $value){ |
|
| 94 | + if ($this->request->getQuery($key) != $value) { |
|
| 95 | 95 | return false; |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -14,10 +14,10 @@ |
||
| 14 | 14 | { |
| 15 | 15 | public function __construct(Throwable $exception) |
| 16 | 16 | { |
| 17 | - $this->path = SUDA_RESOURCE. '/error.php'; |
|
| 17 | + $this->path = SUDA_RESOURCE.'/error.php'; |
|
| 18 | 18 | $type = get_class($exception); |
| 19 | 19 | $this->value = [ |
| 20 | - 'error_type' => $type , |
|
| 20 | + 'error_type' => $type, |
|
| 21 | 21 | 'error_sort_type' => strpos($type, '\\') === false ? $type : substr($type, strrpos($type, '\\') + 1), |
| 22 | 22 | 'error_code' => $exception->getCode(), |
| 23 | 23 | 'error_message' => $exception->getMessage(), |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function __construct($resource = []) |
| 28 | 28 | { |
| 29 | - $this->resource = is_array($resource)?$resource:[$resource]; |
|
| 29 | + $this->resource = is_array($resource) ? $resource : [$resource]; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param string $limitPath 父级溢出 |
| 67 | 67 | * @return string|null |
| 68 | 68 | */ |
| 69 | - public function getResourcePath(string $path, string $limitPath = null):?string |
|
| 69 | + public function getResourcePath(string $path, string $limitPath = null): ?string |
|
| 70 | 70 | { |
| 71 | 71 | foreach ($this->resource as $root) { |
| 72 | 72 | $target = $root.'/'.$path; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param string $path |
| 85 | 85 | * @return string|null |
| 86 | 86 | */ |
| 87 | - public function getConfigResourcePath(string $path):?string |
|
| 87 | + public function getConfigResourcePath(string $path): ?string |
|
| 88 | 88 | { |
| 89 | 89 | foreach ($this->resource as $root) { |
| 90 | 90 | if ($target = PathResolver::resolve($root.'/'.$path)) { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param string $name |
| 78 | 78 | * @return Module|null |
| 79 | 79 | */ |
| 80 | - public function find(string $name):?Module |
|
| 80 | + public function find(string $name): ?Module |
|
| 81 | 81 | { |
| 82 | 82 | return $this->module->get($name); |
| 83 | 83 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $this->modulePaths[] = Resource::getPathByRelativePath($path, $this->path); |
| 112 | 112 | } |
| 113 | 113 | } else { |
| 114 | - $this->modulePaths = [ Resource::getPathByRelativePath('modules', $this->path) ]; |
|
| 114 | + $this->modulePaths = [Resource::getPathByRelativePath('modules', $this->path)]; |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function className(string $name) |
| 136 | 136 | { |
| 137 | - return str_replace(['.','/'], '\\', $name); |
|
| 137 | + return str_replace(['.', '/'], '\\', $name); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param array|Config $extra |
| 112 | 112 | * @return array|null |
| 113 | 113 | */ |
| 114 | - public static function loadConfig(string $path, $extra = []):?array |
|
| 114 | + public static function loadConfig(string $path, $extra = []): ?array |
|
| 115 | 115 | { |
| 116 | 116 | if (!file_exists($path)) { |
| 117 | 117 | $path = PathResolver::resolve($path); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | if ($path) { |
| 123 | 123 | $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
| 124 | - if (in_array($ext, ['yaml','yml','json','php','ini'])) { |
|
| 124 | + if (in_array($ext, ['yaml', 'yml', 'json', 'php', 'ini'])) { |
|
| 125 | 125 | return ContentLoader::{'load'.ucfirst($ext)}($path, $extra); |
| 126 | 126 | } |
| 127 | 127 | return ContentLoader::loadJson($path, $extra); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function __construct(array $methods, string $uri, array $attribute = []) |
| 45 | 45 | { |
| 46 | - array_walk($methods, function ($value) { |
|
| 46 | + array_walk($methods, function($value) { |
|
| 47 | 47 | return strtoupper($value); |
| 48 | 48 | }); |
| 49 | 49 | $this->methods = $methods; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param Request $request |
| 160 | 160 | * @return array|null |
| 161 | 161 | */ |
| 162 | - public function match(Request $request):?array |
|
| 162 | + public function match(Request $request): ?array |
|
| 163 | 163 | { |
| 164 | 164 | if (count($this->methods) > 0 && !in_array($request->getMethod(), $this->methods)) { |
| 165 | 165 | return null; |