@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return string|null |
177 | 177 | */ |
178 | - public function getFetchClass():?string |
|
178 | + public function getFetchClass(): ?string |
|
179 | 179 | { |
180 | 180 | return $this->fetchClass ?? null; |
181 | 181 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return boolean|null |
187 | 187 | */ |
188 | - public function isScroll(bool $set = null):?bool |
|
188 | + public function isScroll(bool $set = null): ?bool |
|
189 | 189 | { |
190 | 190 | if ($set !== null) { |
191 | 191 | $this->scroll = true; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return PDOStatement |
259 | 259 | */ |
260 | - public function getStatement():?PDOStatement |
|
260 | + public function getStatement(): ?PDOStatement |
|
261 | 261 | { |
262 | 262 | return $this->statement; |
263 | 263 | } |
@@ -20,13 +20,13 @@ |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * 取1 |
|
25 | - * |
|
26 | - * @param string|null $class |
|
27 | - * @param array $args |
|
28 | - * @return mixed |
|
29 | - */ |
|
23 | + /** |
|
24 | + * 取1 |
|
25 | + * |
|
26 | + * @param string|null $class |
|
27 | + * @param array $args |
|
28 | + * @return mixed |
|
29 | + */ |
|
30 | 30 | public function one(?string $class = null, array $args = []) |
31 | 31 | { |
32 | 32 | $value = $this->access->run($this->wantOne($class, $args)); |
@@ -42,12 +42,12 @@ |
||
42 | 42 | */ |
43 | 43 | public function field(string $name, string $type, $length = null) |
44 | 44 | { |
45 | - return $this->fields[$name] ?? $this->fields[$name] = ($length?new Field($this->name, $name, $type, $length):new Field($this->name, $name, $type)); |
|
45 | + return $this->fields[$name] ?? $this->fields[$name] = ($length ? new Field($this->name, $name, $type, $length) : new Field($this->name, $name, $type)); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function newField(string $name, string $type, $length = null) |
49 | 49 | { |
50 | - return $this->fields[$name] ?? $this->fields[$name] = ($length?new Field($this->name, $name, $type, $length):new Field($this->name, $name, $type)); |
|
50 | + return $this->fields[$name] ?? $this->fields[$name] = ($length ? new Field($this->name, $name, $type, $length) : new Field($this->name, $name, $type)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | public function getField(string $name) |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function parse(string $modifier) |
47 | 47 | { |
48 | - $this->tokens = \token_get_all('<?php '. $modifier); |
|
48 | + $this->tokens = \token_get_all('<?php '.$modifier); |
|
49 | 49 | $this->length = count($this->tokens); |
50 | 50 | $this->pos = 1; |
51 | 51 | $this->modifier = []; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | protected function skipWhiteComment() |
110 | 110 | { |
111 | - for ($i = $this->pos + 1; $i < $this->length ; $i++) { |
|
111 | + for ($i = $this->pos + 1; $i < $this->length; $i++) { |
|
112 | 112 | if (is_array($this->tokens[$i])) { |
113 | 113 | if (in_array($this->tokens[$i][0], [T_COMMENT, T_DOC_COMMENT, T_WHITESPACE])) { |
114 | 114 | $this->pos++; |
@@ -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); |
@@ -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 | } |
@@ -139,7 +139,7 @@ |
||
139 | 139 | if (is_string($doc) && preg_match('/@field\s+(\w+)(?:\((.+?)\))?\s+(.+)?$/im', $doc, $match)) { |
140 | 140 | $type = strtoupper($match[1]); |
141 | 141 | $length = static::parseLength($match[2] ?? ''); |
142 | - return [$type, $length , trim($match[3] ?? '')]; |
|
142 | + return [$type, $length, trim($match[3] ?? '')]; |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | return ['text', null, '']; |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | public function input(string $name, $data) |
52 | 52 | { |
53 | 53 | if (array_key_exists($name, $this->processor)) { |
54 | - if ($this->processor[$name] === ObjectMiddleware::SERIALIZE){ |
|
55 | - return $data === null? $data : \serialize($data); |
|
54 | + if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
|
55 | + return $data === null ? $data : \serialize($data); |
|
56 | 56 | } |
57 | - if ($this->processor[$name] === ObjectMiddleware::JSON){ |
|
57 | + if ($this->processor[$name] === ObjectMiddleware::JSON) { |
|
58 | 58 | return \json_encode($data); |
59 | 59 | } |
60 | 60 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | public function output(string $name, $data) |
72 | 72 | { |
73 | 73 | if (array_key_exists($name, $this->processor)) { |
74 | - if ($this->processor[$name] === ObjectMiddleware::SERIALIZE){ |
|
74 | + if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
|
75 | 75 | return \unserialize($data) ?: null; |
76 | 76 | } |
77 | - if ($this->processor[$name] === ObjectMiddleware::JSON){ |
|
77 | + if ($this->processor[$name] === ObjectMiddleware::JSON) { |
|
78 | 78 | return \json_decode($data); |
79 | 79 | } |
80 | 80 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | if ($doc = $property->getDocComment()) { |
108 | 108 | if (is_string($doc) && preg_match('/@var\s+(\w+)/i', $doc, $match)) { |
109 | 109 | $type = \strtolower($match[1]); |
110 | - if (\in_array($type, ['boolean', 'bool', 'integer', 'int' , 'float' , 'double', 'string'])) { |
|
110 | + if (\in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string'])) { |
|
111 | 111 | return ObjectMiddleware::RAW; |
112 | 112 | } |
113 | 113 | } |