Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
Minor style cleanup and minor bug fix from CodeClimate
Browse files Browse the repository at this point in the history
  • Loading branch information
Nik Barham committed May 18, 2017
1 parent d6917ac commit 476ade0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ engines:
PhanUndeclaredTrait:
enabled: false
PhanUndeclaredTypeParameter:
enabled: false
enabled: false
PhanUndeclaredClassInstanceof:
enabled: false
ratings:
paths:
- src/**
Expand Down
5 changes: 3 additions & 2 deletions src/ExceptionHandler/DefaultHandler.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?php

namespace Circuit\ExceptionHandler;

use Circuit\Interfaces\ExceptionHandler;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;

class DefaultHandler implements ExceptionHandler
{
function handle(HttpException $e, Request $request, $context) : Response
public function handle(HttpException $e, Request $request, $context) : Response
{
return new Response(
$e->getStatusCode() . ' ' . Response::$statusTexts[$e->getStatusCode()],
$e->getStatusCode(),
['content-type' => 'text/html']
);
}
}
}
2 changes: 1 addition & 1 deletion src/HandlerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Interfaces/ExceptionHandler.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Circuit\Interfaces;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;

interface ExceptionHandler
{
function handle(HttpException $e, Request $request, $context) : Response;
}
public function handle(HttpException $e, Request $request, $context) : Response;
}
2 changes: 1 addition & 1 deletion src/Middleware/ParameterMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function process(Request $request, Delegate $delegate) : Response
foreach ($args as $key => $value) {
if ($key == $p->name) {
$newparams[$var] = $value;
unset ($args[$key]);
unset($args[$key]);
}
}
}
Expand Down
14 changes: 6 additions & 8 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -38,15 +37,15 @@ 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];

/**
* Create a new Router
* 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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -258,7 +256,7 @@ public function setControllerArguments(...$args)
public function registerMiddleware($name, Middleware $middleware)
{
$this->middleware[$name] = $middleware;
return $self;
return $this;
}

/**
Expand Down

0 comments on commit 476ade0

Please sign in to comment.