@@ -26,14 +26,14 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @var Tag[] |
| 28 | 28 | */ |
| 29 | - protected $tags=[]; |
|
| 29 | + protected $tags = []; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * 命令对象 |
| 33 | 33 | * |
| 34 | 34 | * @var CommandInterface[] |
| 35 | 35 | */ |
| 36 | - protected $commands=[]; |
|
| 36 | + protected $commands = []; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * 初始化 |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function registerTag(Tag $tag) |
| 83 | 83 | { |
| 84 | - $this->tags[$tag->getName()] =$tag; |
|
| 84 | + $this->tags[$tag->getName()] = $tag; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | public function compileText(string $text, array $tagConfig = []):string |
| 96 | 96 | { |
| 97 | 97 | $this->applyTagConfig($tagConfig); |
| 98 | - $result = ''; |
|
| 98 | + $result = ''; |
|
| 99 | 99 | foreach (token_get_all($text) as $token) { |
| 100 | 100 | if (is_array($token)) { |
| 101 | 101 | list($tag, $content) = $token; |
| 102 | 102 | // 所有将要编译的文本 |
| 103 | 103 | // 跳过各种的PHP |
| 104 | 104 | if ($tag == T_INLINE_HTML) { |
| 105 | - $content=$this->processTags($content); |
|
| 106 | - $content=$this->processCommands($content); |
|
| 105 | + $content = $this->processTags($content); |
|
| 106 | + $content = $this->processCommands($content); |
|
| 107 | 107 | } |
| 108 | 108 | $result .= $content; |
| 109 | 109 | } else { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | foreach ($this->tags as $tag) { |
| 141 | 141 | $pregExp = sprintf('/(!)?%s\s*(.+?)\s*%s/', preg_quote($tag->getOpen()), preg_quote($tag->getClose())); |
| 142 | - $text = preg_replace_callback($pregExp, function ($match) use ($tag) { |
|
| 142 | + $text = preg_replace_callback($pregExp, function($match) use ($tag) { |
|
| 143 | 143 | if ($match[1] === '!') { |
| 144 | 144 | return substr($match[0], 1); |
| 145 | 145 | } else { |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function processCommands(string $text):string |
| 159 | 159 | { |
| 160 | - $pregExp ='/\B\@(\!)?([\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )? /ux'; |
|
| 161 | - $code = preg_replace_callback($pregExp, [$this,'doMatchCommand'], $text); |
|
| 160 | + $pregExp = '/\B\@(\!)?([\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )? /ux'; |
|
| 161 | + $code = preg_replace_callback($pregExp, [$this, 'doMatchCommand'], $text); |
|
| 162 | 162 | $error = preg_last_error(); |
| 163 | 163 | if ($error !== PREG_NO_ERROR) { |
| 164 | 164 | throw new Exception($error); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | list($input, $ignore, $name, $space) = $match; |
| 175 | 175 | $params = ''; |
| 176 | 176 | } |
| 177 | - if ($ignore ==='!') { |
|
| 177 | + if ($ignore === '!') { |
|
| 178 | 178 | return str_replace('@!', '@', $input); |
| 179 | 179 | } else { |
| 180 | 180 | foreach ($this->commands as $command) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $group = $group ?? $request->getAttribute('group'); |
| 37 | 37 | $default = $default ?? $request->getAttribute('module'); |
| 38 | 38 | $url = $this->route->create($this->getRouteName($name, $default, $group), $parameter, $allowQuery); |
| 39 | - return $this->getUrlIndex($request) . ltrim($url, '/'); |
|
| 39 | + return $this->getUrlIndex($request).ltrim($url, '/'); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $module = $default; |
| 74 | 74 | } |
| 75 | 75 | if ($module !== null && ($moduleObj = $this->find($module))) { |
| 76 | - return $moduleObj->getFullName() . ':' . $name; |
|
| 76 | + return $moduleObj->getFullName().':'.$name; |
|
| 77 | 77 | } |
| 78 | 78 | return $name; |
| 79 | 79 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | $prefixGroup = $this->getRouteGroupPrefix($group); |
| 97 | 97 | if ($module !== null && ($moduleObj = $this->find($module))) { |
| 98 | - return $moduleObj->getFullName() . $prefixGroup . ':' . $name; |
|
| 98 | + return $moduleObj->getFullName().$prefixGroup.':'.$name; |
|
| 99 | 99 | } |
| 100 | 100 | return $name; |
| 101 | 101 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | public function getUriBase(Request $request, bool $beautify = true): string |
| 138 | 138 | { |
| 139 | 139 | $index = $beautify ? $this->getUrlIndex($request) : $request->getIndex(); |
| 140 | - return $request->getUriBase() . $index; |
|
| 140 | + return $request->getUriBase().$index; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -148,6 +148,6 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | protected function getRouteGroupPrefix(?string $group): string |
| 150 | 150 | { |
| 151 | - return $group === null || $group === 'default' ? '' : '@' . $group; |
|
| 151 | + return $group === null || $group === 'default' ? '' : '@'.$group; |
|
| 152 | 152 | } |
| 153 | 153 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ . '/loader.php'; |
|
| 2 | +require_once __DIR__.'/loader.php'; |
|
| 3 | 3 | |
| 4 | 4 | use Swoole\Http\Server; |
| 5 | 5 | use suda\swoole\Request; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | // 初始化系统加载器 |
| 17 | 17 | $loader = new Loader; |
| 18 | 18 | $loader->register(); |
| 19 | -$loader->addIncludePath(SUDA_SYSTEM . '/src', 'suda'); |
|
| 19 | +$loader->addIncludePath(SUDA_SYSTEM.'/src', 'suda'); |
|
| 20 | 20 | // 创建应用 |
| 21 | 21 | $application = ApplicationBuilder::build($loader, SUDA_APP, SUDA_APP_MANIFEST, SUDA_DATA); |
| 22 | 22 | // 注册Debug工具 |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | 'log_file' => $logger->getConfig('save-dump-path').'/swoole.log', |
| 43 | 43 | ]); |
| 44 | 44 | |
| 45 | -$application->getDebug()->setConfig('save-dump-path', SUDA_DEBUG_LOG_PATH . '/dump'); |
|
| 45 | +$application->getDebug()->setConfig('save-dump-path', SUDA_DEBUG_LOG_PATH.'/dump'); |
|
| 46 | 46 | |
| 47 | -$http->on('request', function ($request, $response) use ($application, $logger) { |
|
| 47 | +$http->on('request', function($request, $response) use ($application, $logger) { |
|
| 48 | 48 | // 拷贝副本 |
| 49 | 49 | $runApplication = clone $application; |
| 50 | 50 | $runLogger = clone $logger; |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | use suda\application\builder\ApplicationBuilder; |
| 8 | 8 | use suda\framework\http\HTTPResponse as Response; |
| 9 | 9 | |
| 10 | -require_once __DIR__ . '/loader.php'; |
|
| 10 | +require_once __DIR__.'/loader.php'; |
|
| 11 | 11 | |
| 12 | 12 | // 初始化系统加载器 |
| 13 | 13 | $loader = new Loader; |
| 14 | 14 | $loader->register(); |
| 15 | -$loader->addIncludePath(SUDA_SYSTEM . '/src', 'suda'); |
|
| 15 | +$loader->addIncludePath(SUDA_SYSTEM.'/src', 'suda'); |
|
| 16 | 16 | // 初始化数据目录 |
| 17 | 17 | defined('SUDA_DATA') or define('SUDA_DATA', Path::toAbsolutePath('~/data')); |
| 18 | -defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP . '/manifest'); |
|
| 18 | +defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP.'/manifest'); |
|
| 19 | 19 | $application = ApplicationBuilder::build($loader, SUDA_APP, SUDA_APP_MANIFEST, SUDA_DATA); |
| 20 | 20 | $application->registerDebugger(); |
| 21 | 21 | // 调试信息 |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | 'start-memory' => defined('SUDA_START_MEMORY') ? constant('SUDA_START_MEMORY') : memory_get_usage(), |
| 25 | 25 | ]); |
| 26 | 26 | // 日志路径 |
| 27 | -defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', $application->getDataPath() . '/logs'); |
|
| 27 | +defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', $application->getDataPath().'/logs'); |
|
| 28 | 28 | // 文件日志 |
| 29 | 29 | $logger = new FileLogger( |
| 30 | 30 | [ |
| 31 | 31 | 'log-level' => SUDA_DEBUG_LEVEL, |
| 32 | 32 | 'save-path' => SUDA_DEBUG_LOG_PATH, |
| 33 | - 'save-dump-path' => SUDA_DEBUG_LOG_PATH . '/dump', |
|
| 34 | - 'save-zip-path' => SUDA_DEBUG_LOG_PATH . '/zip', |
|
| 33 | + 'save-dump-path' => SUDA_DEBUG_LOG_PATH.'/dump', |
|
| 34 | + 'save-zip-path' => SUDA_DEBUG_LOG_PATH.'/zip', |
|
| 35 | 35 | 'log-format' => '%message%', |
| 36 | 36 | ] |
| 37 | 37 | ); |
| 38 | 38 | $application->getDebug()->setLogger($logger); |
| 39 | -$application->getDebug()->setConfig('save-dump-path', SUDA_DEBUG_LOG_PATH . '/dump'); |
|
| 39 | +$application->getDebug()->setConfig('save-dump-path', SUDA_DEBUG_LOG_PATH.'/dump'); |
|
| 40 | 40 | $application->run(Request::create(), new Response); |
| 41 | 41 | exit; |