@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | public function log($level, $message, array $context = []) |
| 31 | 31 | { |
| 32 | 32 | if (Debug::compare($level, $this->level) >= 0) { |
| 33 | - print date('Y-m-d H:i:s') . ' ' . $this->interpolate($message, $context) . PHP_EOL; |
|
| 33 | + print date('Y-m-d H:i:s').' '.$this->interpolate($message, $context).PHP_EOL; |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $replace = []; |
| 45 | 45 | foreach ($context as $key => $val) { |
| 46 | - $replace['{' . $key . '}'] = $val; |
|
| 46 | + $replace['{'.$key.'}'] = $val; |
|
| 47 | 47 | } |
| 48 | 48 | return strtr($message, $replace); |
| 49 | 49 | } |
@@ -15,20 +15,20 @@ discard block |
||
| 15 | 15 | use suda\framework\debug\log\logger\MultiLogger; |
| 16 | 16 | use suda\framework\debug\log\logger\ConsoleLogger; |
| 17 | 17 | |
| 18 | -defined('SUDA_APP') or define('SUDA_APP', __DIR__ . '/app'); |
|
| 19 | -defined('SUDA_DATA') or define('SUDA_DATA', __DIR__ . '/data'); |
|
| 20 | -defined('SUDA_PUBLIC') or define('SUDA_PUBLIC', __DIR__ . '/public'); |
|
| 18 | +defined('SUDA_APP') or define('SUDA_APP', __DIR__.'/app'); |
|
| 19 | +defined('SUDA_DATA') or define('SUDA_DATA', __DIR__.'/data'); |
|
| 20 | +defined('SUDA_PUBLIC') or define('SUDA_PUBLIC', __DIR__.'/public'); |
|
| 21 | 21 | defined('SUDA_DEBUG') or define('SUDA_DEBUG', true); |
| 22 | 22 | defined('SUDA_DEBUG_LEVEL') or define('SUDA_DEBUG_LEVEL', 'debug'); |
| 23 | -defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP . '/manifest'); |
|
| 24 | -defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', SUDA_DATA . '/logs'); |
|
| 23 | +defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP.'/manifest'); |
|
| 24 | +defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', SUDA_DATA.'/logs'); |
|
| 25 | 25 | |
| 26 | -require_once __DIR__ . '/loader.php'; |
|
| 26 | +require_once __DIR__.'/loader.php'; |
|
| 27 | 27 | |
| 28 | 28 | // 初始化系统加载器 |
| 29 | 29 | $loader = new Loader; |
| 30 | 30 | $loader->register(); |
| 31 | -$loader->addIncludePath(SUDA_SYSTEM . '/src', 'suda'); |
|
| 31 | +$loader->addIncludePath(SUDA_SYSTEM.'/src', 'suda'); |
|
| 32 | 32 | // 初始化数据目录 |
| 33 | 33 | $application = ApplicationBuilder::build($loader, SUDA_APP, SUDA_APP_MANIFEST, SUDA_DATA); |
| 34 | 34 | |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | [ |
| 38 | 38 | 'log-level' => SUDA_DEBUG_LEVEL, |
| 39 | 39 | 'save-path' => SUDA_DEBUG_LOG_PATH, |
| 40 | - 'save-dump-path' => SUDA_DEBUG_LOG_PATH . '/dump', |
|
| 41 | - 'save-zip-path' => SUDA_DEBUG_LOG_PATH . '/zip', |
|
| 40 | + 'save-dump-path' => SUDA_DEBUG_LOG_PATH.'/dump', |
|
| 41 | + 'save-zip-path' => SUDA_DEBUG_LOG_PATH.'/zip', |
|
| 42 | 42 | 'log-format' => '%message%', |
| 43 | 43 | ] |
| 44 | 44 | ), new ConsoleLogger('warning')); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | /** @var Command $cmd */ |
| 69 | 69 | $className = Loader::realName($item['class']); |
| 70 | 70 | $cmd = new $className; |
| 71 | - $cmd->setName($module->getName() . ':' . $cmd->getName()); |
|
| 71 | + $cmd->setName($module->getName().':'.$cmd->getName()); |
|
| 72 | 72 | if (method_exists($cmd, 'putApplication')) { |
| 73 | 73 | call_user_func_array([$cmd, 'putApplication'], [$application]); |
| 74 | 74 | } |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | $replace = []; |
| 84 | 84 | $attach = []; |
| 85 | 85 | foreach ($context as $key => $val) { |
| 86 | - $replaceKey = '{' . $key . '}'; |
|
| 86 | + $replaceKey = '{'.$key.'}'; |
|
| 87 | 87 | if ($this->canBeStringValue($val) && strpos($message, $replaceKey) !== false) { |
| 88 | - $replace['{' . $key . '}'] = $val; |
|
| 88 | + $replace['{'.$key.'}'] = $val; |
|
| 89 | 89 | } else { |
| 90 | 90 | $attach[$key] = $val; |
| 91 | 91 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); |
| 152 | 152 | $pos = min($pow, count($human) - 1); |
| 153 | 153 | $bytes /= (1 << (10 * $pos)); |
| 154 | - return round($bytes, $precision) . ' ' . $human[$pos]; |
|
| 154 | + return round($bytes, $precision).' '.$human[$pos]; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | protected $ignorePath = [__FILE__]; |
| 13 | 13 | protected $backtrace; |
| 14 | 14 | |
| 15 | - public function __construct(array $backtrace, array $ignorePath =[]) |
|
| 15 | + public function __construct(array $backtrace, array $ignorePath = []) |
|
| 16 | 16 | { |
| 17 | 17 | $this->ignorePath = array_merge($this->ignorePath, $ignorePath); |
| 18 | 18 | $rc = new \ReflectionClass(LoggerTrait::class); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $this->backtrace = $backtrace; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function getCallerTrace():?array |
|
| 26 | + public function getCallerTrace(): ?array |
|
| 27 | 27 | { |
| 28 | 28 | foreach ($this->backtrace as $trace) { |
| 29 | 29 | if (array_key_exists('file', $trace)) { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function prepareQueryMark(string $sql, array $parameter) |
| 22 | 22 | { |
| 23 | 23 | $binders = []; |
| 24 | - $query = preg_replace_callback('/\?/', function ($match) use (&$binders, $parameter) { |
|
| 24 | + $query = preg_replace_callback('/\?/', function($match) use (&$binders, $parameter) { |
|
| 25 | 25 | $index = count($binders); |
| 26 | 26 | if (array_key_exists($index, $parameter)) { |
| 27 | 27 | $name = Binder::index($index); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } else { |
| 33 | 33 | $binder = new Binder($name, $parameter[$index]); |
| 34 | 34 | $binders[] = $binder; |
| 35 | - return ':' . $binder->getName(); |
|
| 35 | + return ':'.$binder->getName(); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | return $match[0]; |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | public function prepareInParameter($values, string $name) |
| 51 | 51 | { |
| 52 | 52 | if ($this->countObject($values) <= 0) { |
| 53 | - throw new SQLException('on field ' . $name . ' value can\'t be empty array'); |
|
| 53 | + throw new SQLException('on field '.$name.' value can\'t be empty array'); |
|
| 54 | 54 | } |
| 55 | 55 | $names = []; |
| 56 | 56 | $binders = []; |
| 57 | 57 | foreach ($values as $value) { |
| 58 | 58 | $_name = Binder::index($name); |
| 59 | 59 | $binders[] = new Binder($_name, $value); |
| 60 | - $names[] = ':' . $_name; |
|
| 60 | + $names[] = ':'.$_name; |
|
| 61 | 61 | } |
| 62 | 62 | return [implode(',', $names), $binders]; |
| 63 | 63 | } |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | public function createQueryOperation(string $name, string $operator, $value, string $indexName = '') |
| 86 | 86 | { |
| 87 | 87 | if ($value instanceof Query) { |
| 88 | - return new Query("`{$name}` {$operator} " . $value, $value->getBinder()); |
|
| 88 | + return new Query("`{$name}` {$operator} ".$value, $value->getBinder()); |
|
| 89 | 89 | } |
| 90 | 90 | if ($value instanceof Statement) { |
| 91 | - return new Query("`{$name}` {$operator} (" . $value->getQuery() . ')', $value->getBinder()); |
|
| 91 | + return new Query("`{$name}` {$operator} (".$value->getQuery().')', $value->getBinder()); |
|
| 92 | 92 | } |
| 93 | 93 | if ($value instanceof IteratorAggregate || is_array($value)) { |
| 94 | 94 | return $this->prepareIn($name, $operator, $value); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | protected function fixWhereArray(array $item) { |
| 161 | 161 | if (count($item) === 2) { |
| 162 | 162 | [$name, $value] = $item; |
| 163 | - $op = $this->isArray($value)?'in':'='; |
|
| 163 | + $op = $this->isArray($value) ? 'in' : '='; |
|
| 164 | 164 | return [$name, $op, $value]; |
| 165 | 165 | } |
| 166 | 166 | return $item; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | if (is_array($value)) { |
| 181 | 181 | $newWhere[] = [$name, $value[0], $value[1]]; |
| 182 | 182 | } else { |
| 183 | - $op = $this->isArray($value)?'in':'='; |
|
| 183 | + $op = $this->isArray($value) ? 'in' : '='; |
|
| 184 | 184 | $newWhere[] = [$name, $op, $value]; |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | return $this->createQueryOperation($name, 'in', $values); |
| 240 | 240 | } |
| 241 | 241 | [$inSQL, $binders] = $this->prepareInParameter($values, $name); |
| 242 | - $sql = '`' . $name . '` ' . strtoupper($operation) . ' (' . $inSQL . ')'; |
|
| 242 | + $sql = '`'.$name.'` '.strtoupper($operation).' ('.$inSQL.')'; |
|
| 243 | 243 | return new Query($sql, $binders); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -254,6 +254,6 @@ discard block |
||
| 254 | 254 | public function replaceQuote(string $name, string $replace, string $target) |
| 255 | 255 | { |
| 256 | 256 | $name = ltrim($name, ':'); |
| 257 | - return preg_replace('/(?<!_):' . preg_quote($name) . '/', $replace, $target); |
|
| 257 | + return preg_replace('/(?<!_):'.preg_quote($name).'/', $replace, $target); |
|
| 258 | 258 | } |
| 259 | 259 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function prepare(Request $request, Response $response) |
| 65 | 65 | { |
| 66 | - $response->setHeader('x-powered-by', 'suda/' . SUDA_VERSION, true); |
|
| 66 | + $response->setHeader('x-powered-by', 'suda/'.SUDA_VERSION, true); |
|
| 67 | 67 | $response->getWrapper()->register(ExceptionContentWrapper::class, [Throwable::class]); |
| 68 | 68 | $response->getWrapper()->register(TemplateWrapper::class, [RawTemplate::class]); |
| 69 | 69 | $this->setCatcher(new RequestDumpCatcher($this, $request, $response)); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | if (!$appResponse->isSend()) { |
| 127 | 127 | $appResponse->end(); |
| 128 | 128 | } |
| 129 | - $this->debug->info('responded with code ' . $appResponse->getStatus()); |
|
| 129 | + $this->debug->info('responded with code '.$appResponse->getStatus()); |
|
| 130 | 130 | $this->debug->timeEnd('sending response'); |
| 131 | 131 | } catch (Throwable $e) { |
| 132 | 132 | $this->debug->uncaughtException($e); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | public function request(array $method, string $name, string $url, array $attributes = []) |
| 150 | 150 | { |
| 151 | 151 | $route = $attributes['config'] ?? []; |
| 152 | - $runnable = RunnableRequestProcessor::class . '->onRequest'; |
|
| 152 | + $runnable = RunnableRequestProcessor::class.'->onRequest'; |
|
| 153 | 153 | if (array_key_exists('class', $route)) { |
| 154 | 154 | $attributes['class'] = $route['class']; |
| 155 | 155 | } elseif (array_key_exists('source', $route)) { |