From 994bee3a349c82636a9b40d6be0083d6bdaa8c73 Mon Sep 17 00:00:00 2001 From: fengqi Date: Thu, 17 Jan 2019 22:18:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E9=9B=86=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Exceptions/UnexpectedValueException.php | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/Exceptions/UnexpectedValueException.php diff --git a/src/Exceptions/UnexpectedValueException.php b/src/Exceptions/UnexpectedValueException.php new file mode 100644 index 0000000..32000cb --- /dev/null +++ b/src/Exceptions/UnexpectedValueException.php @@ -0,0 +1,25 @@ + Date: Thu, 17 Jan 2019 22:19:02 +0800 Subject: [PATCH 2/4] phpdoc --- src/Exceptions/UnauthorizedException.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Exceptions/UnauthorizedException.php b/src/Exceptions/UnauthorizedException.php index 0764e99..88096f9 100644 --- a/src/Exceptions/UnauthorizedException.php +++ b/src/Exceptions/UnauthorizedException.php @@ -11,6 +11,13 @@ */ class UnauthorizedException extends HttpException { + /** + * UnauthorizedException constructor. + * + * @param string $message + * @param int $code + * @param Exception|null $previous + */ public function __construct($message = "", $code = 0, Exception $previous = null) { $headers = array('WWW-Authenticate' => $message); From 6506af8c19e2ef97be595d34e7d550b6cdd4e7ea Mon Sep 17 00:00:00 2001 From: fengqi Date: Thu, 17 Jan 2019 22:21:15 +0800 Subject: [PATCH 3/4] =?UTF-8?q?restful=20=E6=A0=87=E8=AE=B0=E5=BA=9F?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Routing/Router.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Routing/Router.php b/src/Routing/Router.php index 9945a85..1cb7be5 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -192,6 +192,8 @@ public function pattern($param, $pattern) /** * 设置 restful 路由, 自带 GET/POST/PUT/DELETE 四个方法 * + * @deprecated + * * @param $uri * @param $action * From 1d196f660e10fa93530db0cf74bc05a2f91e1740 Mon Sep 17 00:00:00 2001 From: fengqi Date: Thu, 17 Jan 2019 22:22:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8B=BC=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG-1.md | 3 +-- src/App.php | 8 ++++---- src/Console/Kernel.php | 9 +++++---- src/Http/Kernel.php | 6 +++--- src/Pipeline.php | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG-1.md b/CHANGELOG-1.md index 0e1aaec..d539933 100644 --- a/CHANGELOG-1.md +++ b/CHANGELOG-1.md @@ -25,7 +25,6 @@ - 时区从配置文件读取 ## v1.5.1 - -- 命令行添加 `callSystem()` 接口, 允许至今调用系统命令, 如: ls, mkdir, sed, awk 等 +- 命令行添加 `callSystem()` 接口, 允许直接调用系统命令, 如: ls, mkdir, sed, awk 等 - Request 和 Response 使用 [Symfony/http-foundation](https://github.com/symfony/http-foundation) 代替 - 修改 Request 获取 ip, 判断 pjax 问题 diff --git a/src/App.php b/src/App.php index 44f76fd..7ca5469 100644 --- a/src/App.php +++ b/src/App.php @@ -110,13 +110,13 @@ public function bootstrap() $instances = $class->register(); if (is_object($instances)) { - $this->register($accessor, $instances); + static::register($accessor, $instances); continue; } if (!is_array($instances)) continue; foreach ($instances as $abstract => $instance) { - $this->register($accessor.'.'.$abstract, $instance); + static::register($accessor.'.'.$abstract, $instance); } } @@ -132,7 +132,7 @@ public function bootstrap() public function run() { if ($this->runningInConsole()) { - $kernel = $kernel = $this->make('ConsoleKernel'); + $kernel = $kernel = static::make('ConsoleKernel'); $input = new Input(); $output = new Output(); @@ -144,7 +144,7 @@ public function run() exit($status); } else { - $kernel = $this->make('HttpKernel'); + $kernel = static::make('HttpKernel'); $request = Request::createFromGlobals(); $request::enableHttpMethodParameterOverride(); diff --git a/src/Console/Kernel.php b/src/Console/Kernel.php index 778914b..f165cc0 100644 --- a/src/Console/Kernel.php +++ b/src/Console/Kernel.php @@ -47,6 +47,7 @@ public function __construct(App $app) * @param Output|null $output * * @return int + * @throws \Exception */ public function handle(Input $input, Output $output = null) { @@ -58,13 +59,13 @@ public function handle(Input $input, Output $output = null) require $this->app->basePath.'/bootstrap/routes.php'; // 注册 Router - $this->app->register('router', $router); + $this->app::register('router', $router); // 注册 Input - $this->app->register('input', $input); + $this->app::register('input', $input); // 测试 Output - $this->app->register('output', $output); + $this->app::register('output', $output); // 获取命令列表 $commands = require $this->app->basePath.'/bootstrap/commands.php'; @@ -89,7 +90,7 @@ public function resolveCommands($commands) $consoleApp->add(new $command); } - $this->app->register('consoleApp', $consoleApp); + $this->app::register('consoleApp', $consoleApp); return $consoleApp; } diff --git a/src/Http/Kernel.php b/src/Http/Kernel.php index 196f824..2e99f81 100644 --- a/src/Http/Kernel.php +++ b/src/Http/Kernel.php @@ -50,7 +50,7 @@ public function handle(Request $request) { try { // 注册 Request - $this->app->register('request', $request); + $this->app::register('request', $request); // 启用 App $this->app->bootstrap(); @@ -60,13 +60,13 @@ public function handle(Request $request) require $this->app->basePath.'/bootstrap/routes.php'; // 注册 Router - $this->app->register('router', $router); + $this->app::register('router', $router); // 任务分发 $response = $router->dispatch($request); } catch (Exception $e) { - $this->app->make('log')->error('runtime exception: '. $e->getMessage(), [ + $this->app::make('log')->error('runtime exception: '. $e->getMessage(), [ 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), diff --git a/src/Pipeline.php b/src/Pipeline.php index 9414014..2f209e2 100644 --- a/src/Pipeline.php +++ b/src/Pipeline.php @@ -63,7 +63,7 @@ public function then(Closure $destination) return call_user_func($destination, $passable); }; - // 要传过的管道, 通常是中间件 + // 要穿过的管道, 通常是中间件 $pipes = array_reverse($this->pipes); // 使用 array_reduce 递归调用