src/Router.php
Method process
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function process(Request $request) : Response
{
// Try and run the next middleware
$next = next($this->prerouteMiddleware);
if ($next instanceof Middleware) {
The class Router has a coupling between objects value of 18. Consider to reduce the number of dependencies under 13. Open
Open
class Router implements Delegate, LoggerAwareInterface
{
use LoggerAwareTrait;
const CACHE_KEY = 'routes_v3';
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '209', column '25'). Open
Open
return (new \Circuit\ExceptionHandler\DefaultHandler)->handle($e, $request);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '259', column '23'). Open
Open
throw new \UnexpectedValueException("No middleware registered under name '{$name}'");
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Possibly zero references to use statement for classlike/namespace ParameterDereferencer
(\Circuit\Interfaces\ParameterDereferencer)
Open
Open
use Circuit\Interfaces\ParameterDereferencer;
- Exclude checks
Doc-block of $e
in handleException
contains phpdoc param type \Circuit\Throwable
which is incompatible with the param type \Throwable
declared in the signature Open
Open
* @param Throwable $e The Exception / Error thrown.
- Exclude checks
Argument 2 (args)
is class-string
but \Circuit\Router::log()
takes mixed[]
defined at /code/src/Router.php:309
Open
Open
$this->log("Router: Leaving Middleware: %s", get_class($next));
- Exclude checks
Argument 2 (args)
is string
but \Circuit\Router::log()
takes mixed[]
defined at /code/src/Router.php:309
Open
Open
$this->log("Router: Leaving Middleware: %s", $next);
- Exclude checks
Argument 2 (args)
is float|int
but \Circuit\Router::log()
takes mixed[]
defined at /code/src/Router.php:309
Open
Open
$this->log("Router: ->run() called. Starting clock at REQUEST_TIME+%.2fms", microtime(true) - $starttime);
- Exclude checks
Saw an @param annotation for code,
but it was not found in the param list of function setDefaultExceptionHandler(\Circuit\Interfaces\ExceptionHandler $handler) : \Circuit\Router
Open
Open
* @param string $code HTTP code handler is responsible for
- Exclude checks
Doc-block of $container
in setServiceContainer
contains phpdoc param type \Circuit\Psr\Container\ContainerInterface
which is incompatible with the param type \Psr\Container\ContainerInterface
declared in the signature Open
Open
* @param Psr\Container\ContainerInterface $container Service container passed to controller constructor
- Exclude checks
Argument 2 (args)
is string
but \Circuit\Router::log()
takes mixed[]
defined at /code/src/Router.php:309
Open
Open
$this->log("Router: Calling Middleware: %s", $next);
- Exclude checks
mixed[] $args
is not variadic in comment, but variadic in param (...$args)
Open
Open
* @param mixed[] $args Data to pass to sprintf
- Exclude checks
Argument 2 (args)
is class-string
but \Circuit\Router::log()
takes mixed[]
defined at /code/src/Router.php:309
Open
Open
$this->log("Router: Calling Middleware: %s", get_class($next));
- Exclude checks
Saw an @param annotation for hander,
but it was not found in the param list of function setExceptionHandler(string $code, \Circuit\Interfaces\ExceptionHandler $handler) : \Circuit\Router
Open
Open
* @param ExceptionHandler $hander Handler
- Exclude checks
Saw an @param annotation for hander,
but it was not found in the param list of function setDefaultExceptionHandler(\Circuit\Interfaces\ExceptionHandler $handler) : \Circuit\Router
Open
Open
* @param ExceptionHandler $hander Handler
- Exclude checks
Avoid excessively long variable names like $defaultExceptionHandler. Keep variable name length under 20. Open
Open
public $defaultExceptionHandler = null;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid variables with short names like $e. Configured minimum length is 3. Open
Open
protected function handleException(\Throwable $e, Request $request) : Response
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}