@@ -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->count($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); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | return $this->createQueryOperation($name, 'in', $values); |
| 230 | 230 | } |
| 231 | 231 | list($inSQL, $binders) = $this->prepareInParameter($values, $name); |
| 232 | - $sql = '`' . $name . '` ' . strtoupper($operation) . ' (' . $inSQL . ')'; |
|
| 232 | + $sql = '`'.$name.'` '.strtoupper($operation).' ('.$inSQL.')'; |
|
| 233 | 233 | return new Query($sql, $binders); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -244,6 +244,6 @@ discard block |
||
| 244 | 244 | public function replaceQuote(string $name, string $replace, string $target) |
| 245 | 245 | { |
| 246 | 246 | $name = ltrim($name, ':'); |
| 247 | - return preg_replace('/(?<!_):' . preg_quote($name) . '/', $replace, $target); |
|
| 247 | + return preg_replace('/(?<!_):'.preg_quote($name).'/', $replace, $target); |
|
| 248 | 248 | } |
| 249 | 249 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | protected function whereStringArray(string $where, array $whereBinder) |
| 198 | 198 | { |
| 199 | 199 | list($where, $whereBinder) = $this->prepareWhereString($where, $whereBinder); |
| 200 | - $this->where = 'WHERE ' . $where; |
|
| 200 | + $this->where = 'WHERE '.$where; |
|
| 201 | 201 | $this->binder = $this->mergeBinder($this->binder, $whereBinder); |
| 202 | 202 | } |
| 203 | 203 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | public function groupBy(string $what) |
| 211 | 211 | { |
| 212 | 212 | $what = $this->middleware->inputName($what); |
| 213 | - $this->groupBy = 'GROUP BY `' . $what . '`'; |
|
| 213 | + $this->groupBy = 'GROUP BY `'.$what.'`'; |
|
| 214 | 214 | return $this; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | protected function havingStringArray(string $having, array $havingBinder) |
| 254 | 254 | { |
| 255 | 255 | list($having, $havingBinder) = $this->prepareWhereString($having, $havingBinder); |
| 256 | - $this->having = 'HAVING ' . $having; |
|
| 256 | + $this->having = 'HAVING '.$having; |
|
| 257 | 257 | $this->binder = $this->mergeBinder($this->binder, $havingBinder); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | $what = $this->middleware->inputName($what); |
| 270 | 270 | $order = strtoupper($order); |
| 271 | 271 | if (strlen($this->orderBy) > 0) { |
| 272 | - $this->orderBy .= ',`' . $what . '` ' . $order; |
|
| 272 | + $this->orderBy .= ',`'.$what.'` '.$order; |
|
| 273 | 273 | } else { |
| 274 | - $this->orderBy = 'ORDER BY `' . $what . '` ' . $order; |
|
| 274 | + $this->orderBy = 'ORDER BY `'.$what.'` '.$order; |
|
| 275 | 275 | } |
| 276 | 276 | return $this; |
| 277 | 277 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function limit(int $start, int $length = null) |
| 295 | 295 | { |
| 296 | - $this->limit = 'LIMIT ' . $start . ($length !== null ? ',' . $length : ''); |
|
| 296 | + $this->limit = 'LIMIT '.$start.($length !== null ? ','.$length : ''); |
|
| 297 | 297 | return $this; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | $class = [$class]; |
| 102 | 102 | } |
| 103 | 103 | foreach ($class as $index => $className) { |
| 104 | - $class[$index] = $this->className($className) . '->onRequest'; |
|
| 104 | + $class[$index] = $this->className($className).'->onRequest'; |
|
| 105 | 105 | } |
| 106 | 106 | return $class; |
| 107 | 107 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | protected function prepare(Request $request, Response $response) |
| 86 | 86 | { |
| 87 | - $response->setHeader('x-powered-by', 'suda/' . SUDA_VERSION, true); |
|
| 87 | + $response->setHeader('x-powered-by', 'suda/'.SUDA_VERSION, true); |
|
| 88 | 88 | $response->getWrapper()->register(ExceptionContentWrapper::class, [Throwable::class]); |
| 89 | 89 | $response->getWrapper()->register(TemplateWrapper::class, [RawTemplate::class]); |
| 90 | 90 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | if (!$appResponse->isSend()) { |
| 139 | 139 | $appResponse->end(); |
| 140 | 140 | } |
| 141 | - $this->debug->info('responded with code ' . $appResponse->getStatus()); |
|
| 141 | + $this->debug->info('responded with code '.$appResponse->getStatus()); |
|
| 142 | 142 | $this->debug->timeEnd('sending response'); |
| 143 | 143 | } catch (Throwable $e) { |
| 144 | 144 | $this->debug->uncaughtException($e); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | public function request(array $method, string $name, string $url, array $attributes = []) |
| 162 | 162 | { |
| 163 | 163 | $route = $attributes['config'] ?? []; |
| 164 | - $runnable = RunnableRequestProcessor::class . '->onRequest'; |
|
| 164 | + $runnable = RunnableRequestProcessor::class.'->onRequest'; |
|
| 165 | 165 | if (array_key_exists('class', $route)) { |
| 166 | 166 | $attributes['class'] = $route['class']; |
| 167 | 167 | } elseif (array_key_exists('source', $route)) { |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | public function __construct(string $tableName, string $connection = 'default', bool $raw = false) |
| 27 | 27 | { |
| 28 | 28 | parent::__construct( |
| 29 | - $this->initStruct($tableName,$raw), |
|
| 29 | + $this->initStruct($tableName, $raw), |
|
| 30 | 30 | Database::getDataSource($connection), |
| 31 | 31 | $this); |
| 32 | 32 | } |
@@ -72,8 +72,8 @@ |
||
| 72 | 72 | 'context' => $this->context, |
| 73 | 73 | 'backtrace' => $throwable->getTrace(), |
| 74 | 74 | ]; |
| 75 | - $exceptionHash = md5($throwable->getFile() . $throwable->getLine() . $throwable->getCode()); |
|
| 76 | - $path = $dumpPath . '/' . microtime(true) . '.' . substr($exceptionHash, 0, 8) . '.json'; |
|
| 75 | + $exceptionHash = md5($throwable->getFile().$throwable->getLine().$throwable->getCode()); |
|
| 76 | + $path = $dumpPath.'/'.microtime(true).'.'.substr($exceptionHash, 0, 8).'.json'; |
|
| 77 | 77 | FileSystem::make($dumpPath); |
| 78 | 78 | FileSystem::put($path, json_encode( |
| 79 | 79 | new DebugObject($dumper), |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $group = $group ?? $request->getAttribute('group'); |
| 58 | 58 | $default = $default ?? $request->getAttribute('module'); |
| 59 | 59 | $url = $this->route->create($this->getRouteName($name, $default, $group), $parameter, $allowQuery); |
| 60 | - return $this->getUrlIndex($request) . ltrim($url, '/'); |
|
| 60 | + return $this->getUrlIndex($request).ltrim($url, '/'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | public function getUriBase(Request $request, bool $beautify = true): string |
| 90 | 90 | { |
| 91 | 91 | $index = $beautify ? $this->getUrlIndex($request) : $request->getIndex(); |
| 92 | - return $request->getUriBase() . $index; |
|
| 92 | + return $request->getUriBase().$index; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function getRouteGroupPrefix(?string $group): string |
| 102 | 102 | { |
| 103 | - return $group === null || $group === 'default' ? '' : '@' . $group; |
|
| 103 | + return $group === null || $group === 'default' ? '' : '@'.$group; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | $prefixGroup = $this->getRouteGroupPrefix($group); |
| 140 | 140 | if ($module !== null && ($moduleObj = $this->find($module))) { |
| 141 | - return $moduleObj->getFullName() . $prefixGroup . ':' . $name; |
|
| 141 | + return $moduleObj->getFullName().$prefixGroup.':'.$name; |
|
| 142 | 142 | } |
| 143 | 143 | return $name; |
| 144 | 144 | } |
@@ -2,17 +2,17 @@ |
||
| 2 | 2 | $host = $argv[1] ?? '127.0.0.1:9501'; |
| 3 | 3 | list($ip, $port) = explode(':', $host); |
| 4 | 4 | |
| 5 | -defined('SUDA_APP') or define('SUDA_APP', __DIR__ . '/app'); |
|
| 6 | -defined('SUDA_DATA') or define('SUDA_DATA', __DIR__ . '/data'); |
|
| 7 | -defined('SUDA_SYSTEM') or define('SUDA_SYSTEM', __DIR__ . '/suda'); |
|
| 5 | +defined('SUDA_APP') or define('SUDA_APP', __DIR__.'/app'); |
|
| 6 | +defined('SUDA_DATA') or define('SUDA_DATA', __DIR__.'/data'); |
|
| 7 | +defined('SUDA_SYSTEM') or define('SUDA_SYSTEM', __DIR__.'/suda'); |
|
| 8 | 8 | defined('SUDA_PUBLIC') or define('SUDA_PUBLIC', __DIR__); |
| 9 | 9 | defined('SUDA_DEBUG') or define('SUDA_DEBUG', true); |
| 10 | 10 | defined('SUDA_DEBUG_LEVEL') or define('SUDA_DEBUG_LEVEL', 'debug'); |
| 11 | -defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP . '/manifest'); |
|
| 12 | -defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', SUDA_DATA . '/logs'); |
|
| 11 | +defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP.'/manifest'); |
|
| 12 | +defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', SUDA_DATA.'/logs'); |
|
| 13 | 13 | // 设置IP或者端口 |
| 14 | 14 | defined('SUDA_SWOOLE_IP') or define('SUDA_SWOOLE_IP', $ip); |
| 15 | 15 | defined('SUDA_SWOOLE_PORT') or define('SUDA_SWOOLE_PORT', $port); |
| 16 | 16 | |
| 17 | -require_once __DIR__ . '/vendor/autoload.php'; |
|
| 18 | -require_once SUDA_SYSTEM . '/loader/swoole.php'; |
|
| 19 | 17 | \ No newline at end of file |
| 18 | +require_once __DIR__.'/vendor/autoload.php'; |
|
| 19 | +require_once SUDA_SYSTEM.'/loader/swoole.php'; |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ . '/vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/vendor/autoload.php'; |
|
| 3 | 3 | |
| 4 | 4 | use suda\framework\Config; |
| 5 | 5 | use suda\application\Module; |
@@ -12,21 +12,21 @@ discard block |
||
| 12 | 12 | use suda\application\builder\ApplicationBuilder; |
| 13 | 13 | use suda\application\loader\ApplicationBaseLoader; |
| 14 | 14 | |
| 15 | -defined('SUDA_APP') or define('SUDA_APP', __DIR__ . '/app'); |
|
| 16 | -defined('SUDA_DATA') or define('SUDA_DATA', __DIR__ . '/data'); |
|
| 17 | -defined('SUDA_SYSTEM') or define('SUDA_SYSTEM', __DIR__ . '/suda'); |
|
| 15 | +defined('SUDA_APP') or define('SUDA_APP', __DIR__.'/app'); |
|
| 16 | +defined('SUDA_DATA') or define('SUDA_DATA', __DIR__.'/data'); |
|
| 17 | +defined('SUDA_SYSTEM') or define('SUDA_SYSTEM', __DIR__.'/suda'); |
|
| 18 | 18 | defined('SUDA_PUBLIC') or define('SUDA_PUBLIC', __DIR__); |
| 19 | 19 | defined('SUDA_DEBUG') or define('SUDA_DEBUG', true); |
| 20 | 20 | defined('SUDA_DEBUG_LEVEL') or define('SUDA_DEBUG_LEVEL', 'debug'); |
| 21 | -defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP . '/manifest'); |
|
| 22 | -defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', SUDA_DATA . '/logs'); |
|
| 21 | +defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP.'/manifest'); |
|
| 22 | +defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', SUDA_DATA.'/logs'); |
|
| 23 | 23 | |
| 24 | -require_once SUDA_SYSTEM . '/loader/loader.php'; |
|
| 24 | +require_once SUDA_SYSTEM.'/loader/loader.php'; |
|
| 25 | 25 | |
| 26 | 26 | // 初始化系统加载器 |
| 27 | 27 | $loader = new Loader; |
| 28 | 28 | $loader->register(); |
| 29 | -$loader->addIncludePath(SUDA_SYSTEM . '/src', 'suda'); |
|
| 29 | +$loader->addIncludePath(SUDA_SYSTEM.'/src', 'suda'); |
|
| 30 | 30 | // 初始化数据目录 |
| 31 | 31 | $manifestConfig = ApplicationBuilder::loadManifest(SUDA_APP, SUDA_APP_MANIFEST); |
| 32 | 32 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | [ |
| 41 | 41 | 'log-level' => SUDA_DEBUG_LEVEL, |
| 42 | 42 | 'save-path' => SUDA_DEBUG_LOG_PATH, |
| 43 | - 'save-dump-path' => SUDA_DEBUG_LOG_PATH . '/dump', |
|
| 44 | - 'save-zip-path' => SUDA_DEBUG_LOG_PATH . '/zip', |
|
| 43 | + 'save-dump-path' => SUDA_DEBUG_LOG_PATH.'/dump', |
|
| 44 | + 'save-zip-path' => SUDA_DEBUG_LOG_PATH.'/zip', |
|
| 45 | 45 | 'log-format' => '%message%', |
| 46 | 46 | ] |
| 47 | 47 | ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | /** @var Command $cmd */ |
| 67 | 67 | $className = Loader::realName($item['class']); |
| 68 | 68 | $cmd = new $className; |
| 69 | - $cmd->setName($module->getName() . ':' . $cmd->getName()); |
|
| 69 | + $cmd->setName($module->getName().':'.$cmd->getName()); |
|
| 70 | 70 | $app->add($cmd); |
| 71 | 71 | } |
| 72 | 72 | } |