@@ -6,12 +6,12 @@ |
||
6 | 6 | use suda\framework\http\HTTPRequest; |
7 | 7 | use suda\application\builder\ApplicationBuilder; |
8 | 8 | |
9 | -require_once __DIR__ .'/loader.php'; |
|
9 | +require_once __DIR__.'/loader.php'; |
|
10 | 10 | |
11 | 11 | // 初始化系统加载器 |
12 | 12 | $loader = new Loader; |
13 | 13 | $loader->register(); |
14 | -$loader->addIncludePath(SUDA_SYSTEM .'/src', 'suda'); |
|
14 | +$loader->addIncludePath(SUDA_SYSTEM.'/src', 'suda'); |
|
15 | 15 | // 初始化数据目录 |
16 | 16 | defined('SUDA_DATA') or define('SUDA_DATA', Path::toAbsolutePath('~/data')); |
17 | 17 | $application = ApplicationBuilder::build($loader, SUDA_APP, SUDA_DATA); |
@@ -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 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function isTypeOf($data, string $type) : bool |
46 | 46 | { |
47 | - if (is_object($data) && !\in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string','array','NULL'])) { |
|
47 | + if (is_object($data) && !\in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string', 'array', 'NULL'])) { |
|
48 | 48 | $class = new ReflectionClass($data); |
49 | 49 | $typeRef = new ReflectionClass($type); |
50 | 50 | if ($typeRef->isInterface()) { |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | $this->debug->info('==============================='); |
38 | 38 | $this->debug->time('loading application'); |
39 | 39 | $appLoader->load(); |
40 | - $this->event->exec('application:load-config', [ $this->config ,$this]); |
|
40 | + $this->event->exec('application:load-config', [$this->config, $this]); |
|
41 | 41 | $this->debug->timeEnd('loading application'); |
42 | 42 | $this->debug->time('loading datasource'); |
43 | 43 | $appLoader->loadDataSource(); |
44 | 44 | Table::load($this); |
45 | 45 | DataAccess::load($this); |
46 | - $this->event->exec('application:load-environment', [ $this->config ,$this]); |
|
46 | + $this->event->exec('application:load-environment', [$this->config, $this]); |
|
47 | 47 | $this->debug->timeEnd('loading datasource'); |
48 | 48 | $this->debug->time('loading route'); |
49 | 49 | $appLoader->loadRoute(); |
50 | - $this->event->exec('application:load-route', [$this->route , $this]); |
|
50 | + $this->event->exec('application:load-route', [$this->route, $this]); |
|
51 | 51 | $this->debug->timeEnd('loading route'); |
52 | 52 | $this->debug->info('-------------------------------'); |
53 | 53 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if (!$response->isSended()) { |
100 | 100 | $response->end(); |
101 | 101 | } |
102 | - $this->debug->info('resposned with code '. $response->getStatus()); |
|
102 | + $this->debug->info('resposned with code '.$response->getStatus()); |
|
103 | 103 | $this->debug->timeEnd('sending response'); |
104 | 104 | } catch (\Throwable $e) { |
105 | 105 | $this->debug->uncaughtException($e); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | protected function createResponse(?MatchResult $result, Request $request, Response $response) |
158 | 158 | { |
159 | 159 | if (SUDA_DEBUG) { |
160 | - $response->setHeader('x-route', $result === null?'default':$result->getName()); |
|
160 | + $response->setHeader('x-route', $result === null ? 'default' : $result->getName()); |
|
161 | 161 | } |
162 | 162 | if ($result === null) { |
163 | 163 | $content = $this->defaultResponse($this, $request, $response); |
@@ -56,7 +56,7 @@ |
||
56 | 56 | * @param \suda\orm\middleware\Middleware|null $middleware |
57 | 57 | * @return DataAccess |
58 | 58 | */ |
59 | - public static function new(string $object, ?Middleware $middleware = null):DataAccess |
|
59 | + public static function new(string $object, ?Middleware $middleware = null) : DataAccess |
|
60 | 60 | { |
61 | 61 | return new self($object, $middleware); |
62 | 62 | } |
@@ -178,7 +178,7 @@ |
||
178 | 178 | */ |
179 | 179 | private function inputSerialize($data) |
180 | 180 | { |
181 | - return $data === null? $data : \serialize($data); |
|
181 | + return $data === null ? $data : \serialize($data); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public function input(string $name, $data) |
51 | 51 | { |
52 | 52 | if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
53 | - return $data === null? $data : \serialize($data); |
|
53 | + return $data === null ? $data : \serialize($data); |
|
54 | 54 | } |
55 | 55 | return $data; |
56 | 56 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | if ($doc = $property->getDocComment()) { |
97 | 97 | if (is_string($doc) && preg_match('/@var\s+(\w+)/i', $doc, $match)) { |
98 | 98 | $type = \strtolower($match[1]); |
99 | - if (\in_array($type, ['boolean', 'bool', 'integer', 'int' , 'float' , 'double', 'string'])) { |
|
99 | + if (\in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string'])) { |
|
100 | 100 | return ObjectMiddleware::RAW; |
101 | 101 | } |
102 | 102 | } |