Showing 34 of 34 total issues
The class Container has 12 public methods. Consider refactoring Container to keep number of public methods under 10. Open
class Container implements ContainerInterface
{
private $keys = [];
private $lock = [];
private $raw = [];
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Collection has 11 public methods. Consider refactoring Collection to keep number of public methods under 10. Open
class Collection implements CollectionInterface
{
protected $data = [];
public function __construct(array $items = [])
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Avoid using undefined variables such as '$id' which will lead to PHP notices. Open
return $this->values[$id];
- 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
Missing class import via use statement (line '95', column '23'). Open
throw new \RuntimeException(sprintf('Cannot override locked service "%s".', $key));
- 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 '101', column '20'). Open
return new \ArrayIterator($this->data);
- 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 '79', column '23'). Open
throw new \InvalidArgumentException(sprintf('Key "%s" is not defined.', $key));
- 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 '53', column '23'). Open
throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $key));
- 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
Function register
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function register($container)
{
if (!isset($container['environment'])) {
$container['environment'] = function () {
return new Environment($_SERVER);
- 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
Avoid unused local variables such as '$id'. Open
return $this->values[$id];
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
register accesses the super-global variable $_SERVER. Open
public function register($container)
{
if (!isset($container['environment'])) {
$container['environment'] = function () {
return new Environment($_SERVER);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Assigning \Immortal\Container
to property but \Immortal\App->container
is array{}
Open
$this->container = $container;
- Exclude checks
Reference to undeclared property \Immortal\Components\Router\Router->routes
(Did you mean $route) Open
$this->routes[$route->getIdentifier()] = $route;
- Exclude checks
Class implements undeclared interface \Psr\Container\NotFoundExceptionInterface
Open
class NotFoundException extends ExceptionHandler implements PsrNotFoundException
- Exclude checks
Call to method __construct
from undeclared class \Immortal\Environment
Open
return new Environment($_SERVER);
- Exclude checks
Call to method get
on non-class type array{}
Open
$route->setOutputBuffering($this->container->get('settings')['outputBuffering']);
- Exclude checks
Call to method setContainer
from undeclared class \Immortal\Components\Router\Route
(Did you mean class \Immortal\Components\Router\Router) Open
$route->setContainer($this->container);
- Exclude checks
Argument 1 (new)
is array{}
but \Closure::bindTo()
takes ?object
Open
$callable = $callable->bindTo($this->container);
- Exclude checks
Call to method __construct
from undeclared class \Immortal\Components\Router\RuntimeException
(Did you mean class \RuntimeException) Open
throw new RuntimeException('Router cacheFile directory must be writable');
- Exclude checks
Call to method getIdentifier
from undeclared class \Immortal\Components\Router\Route
(Did you mean class \Immortal\Components\Router\Router) Open
$this->routes[$route->getIdentifier()] = $route;
- Exclude checks
Call to method __construct
from undeclared class \Immortal\Components\Router\InvalidArgumentException
(Did you mean class \InvalidArgumentException) Open
throw new InvalidArgumentException('Route pattern must be a string');
- Exclude checks