Showing 176 of 176 total issues
Avoid using undefined variables such as '::$structure' which will lead to PHP notices. Open
foreach (static::$structure['fields'] as $fieldName => &$fieldDefinition) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Method __construct
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(RequestInterface &$request, ResponseInterface &$response, Application $app = null)
{
//this is important, NEVER forget!
parent::__construct($request, $response, $app);
Method matchCheck
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function matchCheck($uriSplit, $urlSplit, array &$params) : bool
{
$result = false;
if ((strlen($uriSplit) >= 7) && ($uriSplit[0] == '{') && ($uriSplit[strlen($uriSplit) - 1] == '}')) {
Method serialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function serialize($format = self::JSON)
{
if (!is_integer($format)) {
throw new \InvalidArgumentException('Invalid serialization format');
}
Method loadRelation
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function loadRelation(Column &$column, $className, $propName)
{
if (!class_exists($className)) {
throw new ActiveRecordException("The class $className doesn't exists.", 109);
}
Method matchURI
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function matchURI($uri, $url, array &$matchedExpr, array &$matchedGet) : bool
{
if (!is_string($url)) {
throw new \InvalidArgumentException("The URL must be given as a valid string");
}
Consider simplifying this complex logical expression. Open
if ((strcmp($method, RouteInterface::GET) == 0) ||
(strcmp($method, RouteInterface::POST) == 0) ||
(strcmp($method, RouteInterface::PUT) == 0) ||
(strcmp($method, RouteInterface::DELETE) == 0) ||
(strcmp($method, RouteInterface::HEAD) == 0) ||
Function where
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function &where(SelectionCriteria $where) : SQLWrapperInterface
{
//execute the private function 'export'
$exportMethod = new \ReflectionMethod($where, 'export');
$exportMethod->setAccessible(true);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function isFloat
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function isFloat($str) : bool
{
if (!self::isString($str)) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function matchURI
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function matchURI($uri, $url, array &$matchedExpr, array &$matchedGet) : bool
{
if (!is_string($url)) {
throw new \InvalidArgumentException("The URL must be given as a valid string");
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function loadErrorHandlers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function loadErrorHandlers($method) : array
{
$errorHandlers = [];
foreach ($this->routes[$method] as &$currentRoute) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function limitOffsetOrderBy
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function &limitOffsetOrderBy(ResultModifier $mod) : SQLWrapperInterface
{
//execute the private function 'export'
$exportMethod = new \ReflectionMethod($mod, 'export');
$exportMethod->setAccessible(true);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function paramCheck
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected static function paramCheck($urlSplit, $type) : bool
{
if ((!is_int($type)) || ($type < 0) || ($type > 4)) {
throw new RouterException("Invalid parameter type", 100);
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The class Route has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
class Route implements RouteInterface
{
use MatchableRouteTrait;
/**
- 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
The class Application has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13. Open
final class Application
{
use ApplicationDatabaseTrait;
use ApplicationLoggerTrait;
- 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
Method pbkdf2
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function pbkdf2($password, $salt, $keyLength, $count, $algorithm = self::SHA256)
Method __invoke
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __invoke(RequestInterface &$request, ResponseInterface &$response, GenericCollection &$arguments, $controllerArgs = [], Application $app = null);
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(RequestInterface &$controllerRequest, ResponseInterface &$controllerResponse, GenericCollection &$controllerArguments, array &$plugins, Application $app = null)
Method __invoke
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __invoke(RequestInterface &$request, ResponseInterface &$response, GenericCollection &$arguments, $controllerArgs = [], Application $app = null)
Function connect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function connect($name, array $details) : Logger
{
//check for the logger name
if ((!is_string($name)) || (strlen($name) <= 0)) {
throw new \InvalidArgumentException('The logger name must be given as a valid non-empty string');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"