@@ -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 | } |
@@ -9,10 +9,10 @@ |
||
9 | 9 | class StringStream implements Stream |
10 | 10 | { |
11 | 11 | /** |
12 | - * 设置偏移 |
|
13 | - * |
|
14 | - * @var int |
|
15 | - */ |
|
12 | + * 设置偏移 |
|
13 | + * |
|
14 | + * @var int |
|
15 | + */ |
|
16 | 16 | protected $offset = 0; |
17 | 17 | |
18 | 18 | /** |
@@ -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]); |
@@ -17,10 +17,10 @@ |
||
17 | 17 | class ContentWrapper |
18 | 18 | { |
19 | 19 | protected $types = [ |
20 | - [ JsonContentWrapper::class , ['array', JsonSerializable::class],], |
|
21 | - [ HtmlContentWrapper::class , ['boolean', 'integer','double', 'string'],], |
|
22 | - [ NullContentWrapper::class , ['NULL'],], |
|
23 | - [ FileContentWrapper::class , [SplFileObject::class],], |
|
20 | + [ JsonContentWrapper::class , ['array', JsonSerializable::class],], |
|
21 | + [ HtmlContentWrapper::class , ['boolean', 'integer','double', 'string'],], |
|
22 | + [ NullContentWrapper::class , ['NULL'],], |
|
23 | + [ FileContentWrapper::class , [SplFileObject::class],], |
|
24 | 24 | ]; |
25 | 25 | |
26 | 26 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class ContentWrapper |
18 | 18 | { |
19 | 19 | protected $types = [ |
20 | - [ JsonContentWrapper::class , ['array', JsonSerializable::class],], |
|
21 | - [ HtmlContentWrapper::class , ['boolean', 'integer','double', 'string'],], |
|
22 | - [ NullContentWrapper::class , ['NULL'],], |
|
23 | - [ FileContentWrapper::class , [SplFileObject::class],], |
|
20 | + [JsonContentWrapper::class, ['array', JsonSerializable::class], ], |
|
21 | + [HtmlContentWrapper::class, ['boolean', 'integer', 'double', 'string'], ], |
|
22 | + [NullContentWrapper::class, ['NULL'], ], |
|
23 | + [FileContentWrapper::class, [SplFileObject::class], ], |
|
24 | 24 | ]; |
25 | 25 | |
26 | 26 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public static function isTypeOf($data, string $type) : bool |
46 | 46 | { |
47 | 47 | if (is_object($data) |
48 | - && !in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string','array','NULL'])) { |
|
48 | + && !in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string', 'array', 'NULL'])) { |
|
49 | 49 | try { |
50 | 50 | $class = new ReflectionClass($data); |
51 | 51 | $typeRef = new ReflectionClass($type); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param $content |
101 | 101 | * @return ContentWrapperInterface|null |
102 | 102 | */ |
103 | - private function matchWrapper($content):?ContentWrapperInterface |
|
103 | + private function matchWrapper($content): ?ContentWrapperInterface |
|
104 | 104 | { |
105 | 105 | foreach ($this->types as $typeConfig) { |
106 | 106 | list($wrapper, $types) = $typeConfig; |
@@ -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 |
@@ -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 | } |
@@ -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 | /** |