@@ -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->getConfig()->set('save-dump-path', SUDA_DEBUG_LOG_PATH . '/dump'); |
|
39 | +$application->getConfig()->set('save-dump-path', SUDA_DEBUG_LOG_PATH.'/dump'); |
|
40 | 40 | $application->run(Request::create(), new Response); |
41 | 41 | exit; |
@@ -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->getConfig()->set('save-dump-path', SUDA_DEBUG_LOG_PATH . '/dump'); |
|
45 | +$application->getConfig()->set('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; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param string $path |
80 | 80 | * @return Module|null |
81 | 81 | */ |
82 | - public function guess(string $path):?Module |
|
82 | + public function guess(string $path): ?Module |
|
83 | 83 | { |
84 | 84 | foreach ($this->module as $module) { |
85 | 85 | if (FileSystem::isOverflowPath($module->getPath(), $path) === false) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param string $name |
113 | 113 | * @return Module|null |
114 | 114 | */ |
115 | - public function get(string $name):?Module |
|
115 | + public function get(string $name): ?Module |
|
116 | 116 | { |
117 | 117 | $full = $this->getFullName($name); |
118 | 118 | return $this->module[$full] ?? null; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | if (array_key_exists($version, $this->knownsFullName[$sortName])) { |
206 | 206 | return $this->knownsFullName[$sortName][$version]; |
207 | 207 | } |
208 | - return $hasVersion?$sortName.':'.$version:end($this->knownsFullName[$sortName]); |
|
208 | + return $hasVersion ? $sortName.':'.$version : end($this->knownsFullName[$sortName]); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | protected function getLikeName(string $name):string |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | public function packValue(?string $matched) |
33 | 33 | { |
34 | - return $matched ? urlencode($matched): ''; |
|
34 | + return $matched ? urlencode($matched) : ''; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | $this->routes = new RouteCollection; |
45 | 45 | $this->runnable = []; |
46 | - $this->default = new Runnable([__CLASS__ , 'defaultResponse']); |
|
46 | + $this->default = new Runnable([__CLASS__, 'defaultResponse']); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param bool $allowQuery |
301 | 301 | * @return string|null |
302 | 302 | */ |
303 | - public function create(string $name, array $parameter, bool $allowQuery = true):?string |
|
303 | + public function create(string $name, array $parameter, bool $allowQuery = true): ?string |
|
304 | 304 | { |
305 | 305 | if ($matcher = $this->routes->get($name)) { |
306 | 306 | return UriMatcher::buildUri($matcher->getMatcher(), $parameter, $allowQuery); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function log($level, $message, array $context = []) |
19 | 19 | { |
20 | - print date('Y-m-d H:i:s') . ' ' . $this->interpolate($message, $context) . PHP_EOL; |
|
20 | + print date('Y-m-d H:i:s').' '.$this->interpolate($message, $context).PHP_EOL; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $replace = []; |
31 | 31 | foreach ($context as $key => $val) { |
32 | - $replace['{' . $key . '}'] = $val; |
|
32 | + $replace['{'.$key.'}'] = $val; |
|
33 | 33 | } |
34 | 34 | return strtr($message, $replace); |
35 | 35 | } |
@@ -71,13 +71,13 @@ |
||
71 | 71 | ); |
72 | 72 | $exported = []; |
73 | 73 | foreach ($props as $value) { |
74 | - $name = dechex($value->getModifiers()) . '$' . $value->getName(); |
|
74 | + $name = dechex($value->getModifiers()).'$'.$value->getName(); |
|
75 | 75 | $value->setAccessible(true); |
76 | 76 | $exported[$name] = new DebugObject($value->getValue($object), $this->context); |
77 | 77 | } |
78 | 78 | return $exported; |
79 | 79 | } catch (ReflectionException $e) { |
80 | - return 'Err:' . $e->getMessage(); |
|
80 | + return 'Err:'.$e->getMessage(); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 |
@@ -2,17 +2,17 @@ |
||
2 | 2 | $host = $argv[1] ?? '127.0.0.1:9501'; |
3 | 3 | list($ip, $port) = explode(':', $host); |
4 | 4 | |
5 | -define('SUDA_APP', __DIR__ . '/app'); |
|
6 | -define('SUDA_DATA', __DIR__ . '/data'); |
|
7 | -define('SUDA_SYSTEM', __DIR__ . '/suda'); |
|
5 | +define('SUDA_APP', __DIR__.'/app'); |
|
6 | +define('SUDA_DATA', __DIR__.'/data'); |
|
7 | +define('SUDA_SYSTEM', __DIR__.'/suda'); |
|
8 | 8 | define('SUDA_PUBLIC', __DIR__); |
9 | 9 | define('SUDA_DEBUG', true); |
10 | 10 | define('SUDA_DEBUG_LEVEL', 'debug'); |
11 | -define('SUDA_APP_MANIFEST', SUDA_APP . '/manifest'); |
|
11 | +define('SUDA_APP_MANIFEST', SUDA_APP.'/manifest'); |
|
12 | 12 | |
13 | 13 | // 设置IP或者端口 |
14 | 14 | define('SUDA_SWOOLE_IP', $ip); |
15 | 15 | define('SUDA_SWOOLE_PORT', $port); |
16 | 16 | |
17 | -require_once __DIR__ .'/vendor/autoload.php'; |
|
17 | +require_once __DIR__.'/vendor/autoload.php'; |
|
18 | 18 | require_once SUDA_SYSTEM.'/loader/swoole.php'; |
19 | 19 | \ No newline at end of file |
@@ -6,7 +6,7 @@ |
||
6 | 6 | define('SUDA_DEBUG', true); |
7 | 7 | define('SUDA_DEBUG_LEVEL', 'info'); |
8 | 8 | |
9 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
9 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
10 | 10 | require_once SUDA_SYSTEM.'/loader/main.php'; |
11 | 11 | |
12 | 12 |