theahmadzai/Immortal-Framework

View on GitHub

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 = [];
Severity: Minor
Found in src/Component/Container/Container.php by phpmd

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 = [])
Severity: Minor
Found in src/Collection.php by phpmd

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];
Severity: Minor
Found in src/Component/Container/Container.php by phpmd

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));
Severity: Minor
Found in src/Component/Container/Container.php by phpmd

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);
Severity: Minor
Found in src/Collection.php by phpmd

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));
Severity: Minor
Found in src/Component/Container/Container.php by phpmd

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));
Severity: Minor
Found in src/Component/Container/Container.php by phpmd

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);
Severity: Minor
Found in src/ServiceProvider.php - About 25 mins to fix

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];
Severity: Minor
Found in src/Component/Container/Container.php by phpmd

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);
Severity: Minor
Found in src/ServiceProvider.php by phpmd

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;
Severity: Minor
Found in src/App.php by phan

Reference to undeclared property \Immortal\Components\Router\Router->routes (Did you mean $route)
Open

        $this->routes[$route->getIdentifier()] = $route;
Severity: Minor
Found in src/Component/Router/Router.php by phan

Class implements undeclared interface \Psr\Container\NotFoundExceptionInterface
Open

class NotFoundException extends ExceptionHandler implements PsrNotFoundException
Severity: Critical
Found in src/Exception/NotFoundException.php by phan

Call to method __construct from undeclared class \Immortal\Environment
Open

                return new Environment($_SERVER);
Severity: Critical
Found in src/ServiceProvider.php by phan

Call to method get on non-class type array{}
Open

            $route->setOutputBuffering($this->container->get('settings')['outputBuffering']);
Severity: Critical
Found in src/App.php by phan

Call to method setContainer from undeclared class \Immortal\Components\Router\Route (Did you mean class \Immortal\Components\Router\Router)
Open

            $route->setContainer($this->container);
Severity: Critical
Found in src/Component/Router/Router.php by phan

Argument 1 (new) is array{} but \Closure::bindTo() takes ?object
Open

            $callable = $callable->bindTo($this->container);
Severity: Minor
Found in src/App.php by phan

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');
Severity: Critical
Found in src/Component/Router/Router.php by phan

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;
Severity: Critical
Found in src/Component/Router/Router.php by phan

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');
Severity: Critical
Found in src/Component/Router/Router.php by phan
Severity
Category
Status
Source
Language