@@ -132,7 +132,7 @@ |
||
| 132 | 132 | */ |
| 133 | 133 | public function charset(string $charset) |
| 134 | 134 | { |
| 135 | - $this->charset = 'CHARACTER SET ' . $charset; |
|
| 135 | + $this->charset = 'CHARACTER SET '.$charset; |
|
| 136 | 136 | return $this; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | public function input(string $name, $data) |
| 58 | 58 | { |
| 59 | 59 | if (array_key_exists($name, $this->processor)) { |
| 60 | - if ($this->processor[$name] === ObjectMiddleware::SERIALIZE){ |
|
| 61 | - return $data === null? $data : serialize($data); |
|
| 60 | + if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
|
| 61 | + return $data === null ? $data : serialize($data); |
|
| 62 | 62 | } |
| 63 | - if ($this->processor[$name] === ObjectMiddleware::JSON){ |
|
| 63 | + if ($this->processor[$name] === ObjectMiddleware::JSON) { |
|
| 64 | 64 | return json_encode($data); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | public function output(string $name, $data) |
| 78 | 78 | { |
| 79 | 79 | if (array_key_exists($name, $this->processor)) { |
| 80 | - if ($this->processor[$name] === ObjectMiddleware::SERIALIZE){ |
|
| 80 | + if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
|
| 81 | 81 | return unserialize($data) ?: null; |
| 82 | 82 | } |
| 83 | - if ($this->processor[$name] === ObjectMiddleware::JSON){ |
|
| 83 | + if ($this->processor[$name] === ObjectMiddleware::JSON) { |
|
| 84 | 84 | return json_decode($data); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | if ($doc = $property->getDocComment()) { |
| 114 | 114 | if (is_string($doc) && preg_match('/@var\s+(\w+)/i', $doc, $match)) { |
| 115 | 115 | $type = strtolower($match[1]); |
| 116 | - if (in_array($type, ['boolean', 'bool', 'integer', 'int' , 'float' , 'double', 'string'])) { |
|
| 116 | + if (in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string'])) { |
|
| 117 | 117 | return ObjectMiddleware::RAW; |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | private function inputSerialize($data) |
| 197 | 197 | { |
| 198 | - return $data === null? $data : serialize($data); |
|
| 198 | + return $data === null ? $data : serialize($data); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | private function inputJson($data) |
| 219 | 219 | { |
| 220 | - return $data === null? $data : json_encode($data); |
|
| 220 | + return $data === null ? $data : json_encode($data); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -290,7 +290,7 @@ |
||
| 290 | 290 | protected static function createDefaultMiddleware(string $object, TableStruct $struct) |
| 291 | 291 | { |
| 292 | 292 | $reflectObject = new ReflectionClass($object); |
| 293 | - $classDoc = is_string($reflectObject->getDocComment())?$reflectObject->getDocComment():''; |
|
| 293 | + $classDoc = is_string($reflectObject->getDocComment()) ? $reflectObject->getDocComment() : ''; |
|
| 294 | 294 | if (preg_match('/@field-(serialize|json)\s+(\w+)/i', $classDoc, $matchs)) { |
| 295 | 295 | return new TableStructMiddleware($object, $struct); |
| 296 | 296 | } |
@@ -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 | } |
@@ -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); |