attogram/justrefs

View on GitHub
src/Base.php

Summary

Maintainability
A
0 mins
Test Coverage

The method Base::formatMessage() calls the typical debug function print_r() which is mostly only used during development.
Open

            . ': ' . htmlentities(print_r($message, true));
Severity: Minor
Found in src/Base.php by phpmd

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

The method __construct has a boolean flag argument $verbose, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function __construct($verbose = false, $router = null, $template = null)
Severity: Minor
Found in src/Base.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Duplicated array key , first declared at line 188.
Open

        $replacers = [
            ' ' => '_',
            '%' => '%25', // do first before any other %## replacers
            '"' => '%22',
            '&' => '%26',
Severity: Minor
Found in src/Base.php by phpmd

DuplicatedArrayKey

Defining another value for the same key in an array literal overrides the previous key/value, which makes it effectively an unused code. If it's known from the beginning that the key will have different value, there is usually no point in defining first one.

Example

function createArray() {
    return [
        'non-associative 0element', // not applied
        0 => 'associative 0-element', // applied
        false => 'associative 0-element', // applied
        'foo' => 'bar', // not applied
        "foo" => 'baz', // applied
    ];
}

Source http://phpmd.org/rules/cleancode.html#duplicatedarraykey

Missing class import via use statement (line '163', column '21').
Open

        return (new \DateTime())->format('u') . ': ' . get_class($this)
Severity: Minor
Found in src/Base.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

The method error404() contains an exit expression.
Open

        exit;
Severity: Minor
Found in src/Base.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

There are no issues that match your filters.

Category
Status