From 476ade0d0072b627740e1e06c9d7a6e633f88b23 Mon Sep 17 00:00:00 2001 From: Nik Barham Date: Thu, 18 May 2017 12:53:46 +0000 Subject: [PATCH] Minor style cleanup and minor bug fix from CodeClimate --- .codeclimate.yml | 4 +++- src/ExceptionHandler/DefaultHandler.php | 5 +++-- src/HandlerContainer.php | 2 +- src/Interfaces/ExceptionHandler.php | 5 +++-- src/Middleware/ParameterMatcher.php | 2 +- src/Router.php | 14 ++++++-------- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index de185d2..76c55ec 100755 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -33,7 +33,9 @@ engines: PhanUndeclaredTrait: enabled: false PhanUndeclaredTypeParameter: - enabled: false + enabled: false + PhanUndeclaredClassInstanceof: + enabled: false ratings: paths: - src/** diff --git a/src/ExceptionHandler/DefaultHandler.php b/src/ExceptionHandler/DefaultHandler.php index f7e0252..45add9e 100644 --- a/src/ExceptionHandler/DefaultHandler.php +++ b/src/ExceptionHandler/DefaultHandler.php @@ -1,6 +1,7 @@ getStatusCode() . ' ' . Response::$statusTexts[$e->getStatusCode()], @@ -16,4 +17,4 @@ function handle(HttpException $e, Request $request, $context) : Response ['content-type' => 'text/html'] ); } -} \ No newline at end of file +} diff --git a/src/HandlerContainer.php b/src/HandlerContainer.php index 4e6d382..56393af 100644 --- a/src/HandlerContainer.php +++ b/src/HandlerContainer.php @@ -19,7 +19,7 @@ class HandlerContainer implements Delegate /** @var string The method to call on the Controller for this route*/ public $controllerMethod; - /** @var Circuit\Router The router responsible for this route - this gets assigned when a route is executed */ + /** @var \Circuit\Router The router responsible for this route - this gets assigned when a route is executed */ protected $router; /** diff --git a/src/Interfaces/ExceptionHandler.php b/src/Interfaces/ExceptionHandler.php index f79e03e..f8719c4 100644 --- a/src/Interfaces/ExceptionHandler.php +++ b/src/Interfaces/ExceptionHandler.php @@ -1,11 +1,12 @@ $value) { if ($key == $p->name) { $newparams[$var] = $value; - unset ($args[$key]); + unset($args[$key]); } } } diff --git a/src/Router.php b/src/Router.php index 17d6532..4806c60 100644 --- a/src/Router.php +++ b/src/Router.php @@ -21,8 +21,7 @@ class Router implements Delegate protected $routeCollection; protected $dispatcher; - /** @var Psr\SimpleCache\CacheInterface|Psr\Cache\CacheItemPoolInterface - PSR6/16 compatible cache item + /** @var Psr16|Psr6 PSR6/16 compatible cache item */ protected $cache; @@ -38,7 +37,7 @@ class Router implements Delegate /** @var Middleware[] List of registered middlewares on this router */ protected $middleware = []; - /** @var mixed[] List of middlewares to run before matching routes */ + /** @var array List of middlewares to run before matching routes */ protected $preRouteMiddlewareStack = [null]; /** @@ -46,7 +45,7 @@ class Router implements Delegate * See https://github.com/nikic/FastRoute for more details * * @param array $options Option overrides - * @param Psr\SimpleCache\CacheInterface|Psr\Cache\CacheItemPoolInterface $cache A PSR-6 or PSR-16 compatible Cache object + * @param Psr16|Psr6 $cache A PSR-6 or PSR-16 compatible Cache object */ public function __construct(array $options = [], $cache = null) { @@ -115,7 +114,6 @@ public function defineRoutes(callable $routeDefinitionCallback) * Internal function to retrieve a cached value from PSR-6/16 cache object * * @param string $key Cache key to retrieve from cache - * @return self */ protected function getCachedValue($key) { @@ -153,7 +151,7 @@ public function run(Request $request) * Will call pre-route middleware, then match route and execute that route (more middleware + controller) * * @param Request $request Request object for current process - * @return Response Response to http request ready for dispatch + * @return Response Response to http request ready for dispatch */ public function process(Request $request) : Response { @@ -199,7 +197,7 @@ public function process(Request $request) : Response * @param Request $request The request that caused the exception. * @param mixed $currentContext Some data to try and guess the context from. * @return Response The response to the exception (e.g. error page) - */ + */ protected function handleException(\Throwable $e, Request $request, $currentContext = null) : Response { // Figure out which Middleware/Controller we're in @@ -258,7 +256,7 @@ public function setControllerArguments(...$args) public function registerMiddleware($name, Middleware $middleware) { $this->middleware[$name] = $middleware; - return $self; + return $this; } /**