@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param mixed $default |
| 26 | 26 | * @return mixed |
| 27 | 27 | */ |
| 28 | - public function get(string $name, $default=null); |
|
| 28 | + public function get(string $name, $default = null); |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * 删除一个或者全部Cache数据 |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param string|null $name |
| 34 | 34 | * @return bool |
| 35 | 35 | */ |
| 36 | - public function delete(?string $name=null):bool; |
|
| 36 | + public function delete(?string $name = null):bool; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * 检测是否存在Cache |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | if (is_string($id = $request->getCookie($name))) { |
| 67 | 67 | session_id($id); |
| 68 | - }else{ |
|
| 68 | + } else { |
|
| 69 | 69 | $id = md5($path.$request->getRemoteAddr().uniqid()); |
| 70 | 70 | session_id($id); |
| 71 | 71 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | public function get(string $name = null, $default = null) |
| 101 | 101 | { |
| 102 | 102 | if ($name !== null) { |
| 103 | - return $this->has($name) ?$_SESSION[$name]:$default; |
|
| 103 | + return $this->has($name) ? $_SESSION[$name] : $default; |
|
| 104 | 104 | } else { |
| 105 | 105 | return $_SESSION; |
| 106 | 106 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | { |
| 23 | 23 | $content = $this->content; |
| 24 | 24 | $response->setType($content->getExtension()); |
| 25 | - $response->setHeader('Content-Disposition', 'attachment;filename="' . $content->getBasename().'"'); |
|
| 25 | + $response->setHeader('Content-Disposition', 'attachment;filename="'.$content->getBasename().'"'); |
|
| 26 | 26 | $response->setHeader('Cache-Control', 'max-age=0'); |
| 27 | 27 | return new DataStream($content); |
| 28 | 28 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @var array |
| 13 | 13 | */ |
| 14 | - private $locales=[]; |
|
| 14 | + private $locales = []; |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * 包含本地化语言数组 |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public static function format(string $string, array $param) |
| 51 | 51 | { |
| 52 | - return preg_replace_callback('/(?<!\$)\$(\{)?(\d+|\w+?\b)(?(1)\})/', function ($match) use ($param) { |
|
| 52 | + return preg_replace_callback('/(?<!\$)\$(\{)?(\d+|\w+?\b)(?(1)\})/', function($match) use ($param) { |
|
| 53 | 53 | $key = $match[2]; |
| 54 | 54 | if (array_key_exists($key, $param)) { |
| 55 | 55 | return strval($param[$key]); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $this->routes = new RouteCollection; |
| 44 | 44 | $this->runnable = []; |
| 45 | - $this->default = new Runnable([__CLASS__ , 'defaultResponse']); |
|
| 45 | + $this->default = new Runnable([__CLASS__, 'defaultResponse']); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @param boolean $allowQuery |
| 290 | 290 | * @return string|null |
| 291 | 291 | */ |
| 292 | - public function create(string $name, array $parameter, bool $allowQuery = true):?string |
|
| 292 | + public function create(string $name, array $parameter, bool $allowQuery = true): ?string |
|
| 293 | 293 | { |
| 294 | 294 | if ($matcher = $this->routes->get($name)) { |
| 295 | 295 | return UriMatcher::buildUri($matcher->getMatcher(), $parameter, $allowQuery); |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | |
| 25 | 25 | public function packValue(?string $matched) |
| 26 | 26 | { |
| 27 | - return $matched ? urlencode($matched): ''; |
|
| 27 | + return $matched ? urlencode($matched) : ''; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -230,7 +230,7 @@ |
||
| 230 | 230 | protected function closeOutputBuffer(bool $flush) |
| 231 | 231 | { |
| 232 | 232 | while (ob_get_level() > 0) { |
| 233 | - $flush?ob_end_flush():ob_end_clean(); |
|
| 233 | + $flush ?ob_end_flush() : ob_end_clean(); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
@@ -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 | } |