@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | public function getSourcePath(): ?string |
| 25 | 25 | { |
| 26 | 26 | $subfix = $this->config['subfix'] ?? '.tpl.html'; |
| 27 | - return $this->getResource($this->module)->getResourcePath($this->getTemplatePath() . '/' . $this->name . $subfix); |
|
| 27 | + return $this->getResource($this->module)->getResourcePath($this->getTemplatePath().'/'.$this->name.$subfix); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function getPath() |
| 36 | 36 | { |
| 37 | - $output = $this->config['output'] ?? $this->application->getDataPath() . '/template/' . $this->uriName; |
|
| 37 | + $output = $this->config['output'] ?? $this->application->getDataPath().'/template/'.$this->uriName; |
|
| 38 | 38 | FileSystem::make($output); |
| 39 | - return $output . '/' . $this->name . '.php'; |
|
| 39 | + return $output.'/'.$this->name.'.php'; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | public function getRenderedString() |
| 58 | 58 | { |
| 59 | - $this->application->debug()->time('render ' . $this->name); |
|
| 59 | + $this->application->debug()->time('render '.$this->name); |
|
| 60 | 60 | $code = parent::getRenderedString(); |
| 61 | - $this->application->debug()->timeEnd('render ' . $this->name); |
|
| 61 | + $this->application->debug()->timeEnd('render '.$this->name); |
|
| 62 | 62 | return $code; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | protected function compile() |
| 66 | 66 | { |
| 67 | 67 | if ($this->isCompiled() === false) { |
| 68 | - $this->application->debug()->time('compile ' . $this->name); |
|
| 68 | + $this->application->debug()->time('compile '.$this->name); |
|
| 69 | 69 | $result = parent::compile(); |
| 70 | - $this->application->debug()->timeEnd('compile ' . $this->name); |
|
| 70 | + $this->application->debug()->timeEnd('compile '.$this->name); |
|
| 71 | 71 | return $result; |
| 72 | 72 | } |
| 73 | 73 | return true; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | return $this->application->getUrl($this->request, $name, $values ?? [], true, $this->module, $this->group); |
| 107 | 107 | } elseif (is_string($defaultName)) { |
| 108 | - $parameter = is_array($name)?array_merge($query, $name):$query; |
|
| 108 | + $parameter = is_array($name) ?array_merge($query, $name) : $query; |
|
| 109 | 109 | return $this->application->getUrl( |
| 110 | 110 | $this->request, |
| 111 | 111 | $defaultName, |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $this->group |
| 116 | 116 | ); |
| 117 | 117 | } |
| 118 | - return '#' . $defaultName; |
|
| 118 | + return '#'.$defaultName; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | return ob_get_clean(); |
| 99 | 99 | } |
| 100 | 100 | throw new NoTemplateFoundException( |
| 101 | - 'missing dest at ' . $this->getPath(), |
|
| 101 | + 'missing dest at '.$this->getPath(), |
|
| 102 | 102 | E_USER_ERROR, |
| 103 | 103 | $this->getPath(), |
| 104 | 104 | 1 |
@@ -43,17 +43,17 @@ discard block |
||
| 43 | 43 | $this->debug->info('==============================='); |
| 44 | 44 | $this->debug->time('loading application'); |
| 45 | 45 | $appLoader->load(); |
| 46 | - $this->event->exec('application:load-config', [ $this->config ,$this]); |
|
| 46 | + $this->event->exec('application:load-config', [$this->config, $this]); |
|
| 47 | 47 | $this->debug->timeEnd('loading application'); |
| 48 | 48 | $this->debug->time('loading data-source'); |
| 49 | 49 | $appLoader->loadDataSource(); |
| 50 | 50 | $this->debug->timeEnd('loading data-source'); |
| 51 | 51 | Table::load($this); |
| 52 | 52 | DataAccess::loadApplication($this); |
| 53 | - $this->event->exec('application:load-environment', [ $this->config ,$this]); |
|
| 53 | + $this->event->exec('application:load-environment', [$this->config, $this]); |
|
| 54 | 54 | $this->debug->time('loading route'); |
| 55 | 55 | $appLoader->loadRoute(); |
| 56 | - $this->event->exec('application:load-route', [$this->route , $this]); |
|
| 56 | + $this->event->exec('application:load-route', [$this->route, $this]); |
|
| 57 | 57 | $this->debug->timeEnd('loading route'); |
| 58 | 58 | $this->debug->info('-------------------------------'); |
| 59 | 59 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if (!$response->isSend()) { |
| 110 | 110 | $response->end(); |
| 111 | 111 | } |
| 112 | - $this->debug->info('responded with code '. $response->getStatus()); |
|
| 112 | + $this->debug->info('responded with code '.$response->getStatus()); |
|
| 113 | 113 | $this->debug->timeEnd('sending response'); |
| 114 | 114 | } catch (Throwable $e) { |
| 115 | 115 | $this->debug->uncaughtException($e); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | protected function createResponse(?MatchResult $result, Request $request, Response $response) |
| 177 | 177 | { |
| 178 | 178 | if (SUDA_DEBUG) { |
| 179 | - $response->setHeader('x-route', $result === null?'default':$result->getName()); |
|
| 179 | + $response->setHeader('x-route', $result === null ? 'default' : $result->getName()); |
|
| 180 | 180 | } |
| 181 | 181 | if ($result === null) { |
| 182 | 182 | $content = $this->defaultResponse($this, $request, $response); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $this->config = $config; |
| 80 | 80 | $this->name = $name ?? 'anonymous'; |
| 81 | 81 | $this->observer = new NullObserver; |
| 82 | - register_shutdown_function(function () { |
|
| 82 | + register_shutdown_function(function() { |
|
| 83 | 83 | $this->onBeforeSystemShutdown(); |
| 84 | 84 | }); |
| 85 | 85 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | try { |
| 108 | 108 | $this->pdo = $this->createPDO(); |
| 109 | 109 | $this->id = static::$connectionCount; |
| 110 | - static::$connectionCount ++; |
|
| 110 | + static::$connectionCount++; |
|
| 111 | 111 | } catch (PDOException $e) { |
| 112 | 112 | throw new SQLException(sprintf( |
| 113 | 113 | "%s connect database error:%s", |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function beginTransaction() |
| 182 | 182 | { |
| 183 | - $this->transaction ++; |
|
| 183 | + $this->transaction++; |
|
| 184 | 184 | if ($this->transaction == 1) { |
| 185 | 185 | $this->pdo->beginTransaction(); |
| 186 | 186 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | * @param string $query |
| 371 | 371 | * @return string |
| 372 | 372 | */ |
| 373 | - public function prefix( string $query):string |
|
| 373 | + public function prefix(string $query):string |
|
| 374 | 374 | { |
| 375 | 375 | // _:table 前缀控制 |
| 376 | 376 | $prefix = $this->getConfig('prefix', ''); |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | public function register() |
| 39 | 39 | { |
| 40 | - set_exception_handler([$this,'uncaughtException']); |
|
| 40 | + set_exception_handler([$this, 'uncaughtException']); |
|
| 41 | 41 | return $this; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | protected function whereStringArray(string $where, array $whereBinder) |
| 145 | 145 | { |
| 146 | 146 | list($where, $whereBinder) = $this->prepareWhereString($where, $whereBinder); |
| 147 | - $this->where = 'WHERE '. $where; |
|
| 147 | + $this->where = 'WHERE '.$where; |
|
| 148 | 148 | $this->binder = $this->mergeBinder($this->binder, $whereBinder); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function groupBy(string $what) |
| 158 | 158 | { |
| 159 | - $this->groupBy = 'GROUP BY '. $what; |
|
| 159 | + $this->groupBy = 'GROUP BY '.$what; |
|
| 160 | 160 | return $this; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | { |
| 201 | 201 | |
| 202 | 202 | list($having, $havingBinder) = $this->prepareWhereString($having, $havingBinder); |
| 203 | - $this->having = 'HAVING '. $having; |
|
| 203 | + $this->having = 'HAVING '.$having; |
|
| 204 | 204 | $this->binder = $this->mergeBinder($this->binder, $havingBinder); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function orderBy(string $what, string $order = 'ASC') |
| 215 | 215 | { |
| 216 | - $this->orderBy = 'ORDER BY '. $what.' '. $order; |
|
| 216 | + $this->orderBy = 'ORDER BY '.$what.' '.$order; |
|
| 217 | 217 | return $this; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function limit(int $start, int $length = null) |
| 228 | 228 | { |
| 229 | - $this->limit = 'LIMIT '. $start . ($length !== null ? ',' .$length :''); |
|
| 229 | + $this->limit = 'LIMIT '.$start.($length !== null ? ','.$length : ''); |
|
| 230 | 230 | return $this; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | protected function prepareQuery():Query |
| 255 | 255 | { |
| 256 | - $where = [$this->where,$this->groupBy,$this->having,$this->orderBy,$this->limit]; |
|
| 256 | + $where = [$this->where, $this->groupBy, $this->having, $this->orderBy, $this->limit]; |
|
| 257 | 257 | $condition = implode(' ', array_filter(array_map('trim', $where), 'strlen')); |
| 258 | - $select = [$this->distinct,$this->select]; |
|
| 258 | + $select = [$this->distinct, $this->select]; |
|
| 259 | 259 | $selection = implode(' ', array_filter(array_map('trim', $select), 'strlen')); |
| 260 | 260 | $string = sprintf("SELECT %s FROM %s %s", $selection, $this->table, $condition); |
| 261 | 261 | return new Query($string, $this->binder); |