SergioMadness/pwf

View on GitHub
framework/basic/Application.php

Summary

Maintainability
A
1 hr
Test Coverage

runController accesses the super-global variable $_GET.
Open

    public function runController($handler, array $params = [])
    {
        return SystemHelpers::call(
                $this->prepareCallback($handler),
                function($paramName) use ($params) {
Severity: Minor
Found in framework/basic/Application.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

runController accesses the super-global variable $_POST.
Open

    public function runController($handler, array $params = [])
    {
        return SystemHelpers::call(
                $this->prepareCallback($handler),
                function($paramName) use ($params) {
Severity: Minor
Found in framework/basic/Application.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

runController accesses the super-global variable $_POST.
Open

    public function runController($handler, array $params = [])
    {
        return SystemHelpers::call(
                $this->prepareCallback($handler),
                function($paramName) use ($params) {
Severity: Minor
Found in framework/basic/Application.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

runController accesses the super-global variable $_GET.
Open

    public function runController($handler, array $params = [])
    {
        return SystemHelpers::call(
                $this->prepareCallback($handler),
                function($paramName) use ($params) {
Severity: Minor
Found in framework/basic/Application.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

__construct accesses the super-global variable $_REQUEST.
Open

    public function __construct($config = [])
    {
        $this->request  = new Request($_REQUEST);
        $this->response = new Response();
        if (!isset($config[self::COMPONENT_CONFIG_BLOCK])) {
Severity: Minor
Found in framework/basic/Application.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

Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function run()
    {
        try {
            $this->trigger(self::EVENT_APPLICATION_RUN);

Severity: Minor
Found in framework/basic/Application.php - About 1 hr to fix

    Function forceComponentLoading has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function forceComponentLoading()
        {
            $config = $this->getConfiguration();
            foreach ($config[self::COMPONENT_CONFIG_BLOCK] as $key => $params) {
                if (isset($params['class']) && isset($params['force'])) {
    Severity: Minor
    Found in framework/basic/Application.php - About 35 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

    Missing class import via use statement (line '293', column '27').
    Open

                    throw new \Exception('Component must implement \'Component\' interface',
    Severity: Minor
    Found in framework/basic/Application.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

    Avoid using static access to class 'pwf\basic\RouteHandler' in method 'run'.
    Open

                $callback = $this->prepareCallback(RouteHandler::getHandler($this->request->getPath()));
    Severity: Minor
    Found in framework/basic/Application.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '216', column '22').
    Open

        public function runController($handler, array $params = [])
        {
            return SystemHelpers::call(
                    $this->prepareCallback($handler),
                    function($paramName) use ($params) {
    Severity: Minor
    Found in framework/basic/Application.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    Avoid using static access to class '\pwf\helpers\SystemHelpers' in method 'runController'.
    Open

            return SystemHelpers::call(
                    $this->prepareCallback($handler),
                    function($paramName) use ($params) {
                    if (($component = $this->getComponent($paramName)) !== null) {
                        return $component;
    Severity: Minor
    Found in framework/basic/Application.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '258', column '54').
    Open

        public function getComponent($name)
        {
            if (!isset($this->componentCache[$name]) && ($this->componentCache[$name]
                = $this->createComponent($name)) !== null) {
                $this->componentCache[$name]->init();
    Severity: Minor
    Found in framework/basic/Application.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    The method getConfigParam uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $result = null;
                    break;
                }
    Severity: Minor
    Found in framework/basic/Application.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Expected 1 space after FUNCTION keyword; 0 found
    Open

                    function($paramName) use ($params) {

    Line indented incorrectly; expected 20 spaces, found 16
    Open

                    if (isset($_POST[$paramName])) {

    Multi-line function call not indented correctly; expected 8 spaces but found 12
    Open

                });

    Opening parenthesis of a multi-line function call must be the last content on the line
    Open

                    throw new \Exception('Component must implement \'Component\' interface',

    Opening parenthesis of a multi-line function call must be the last content on the line
    Open

                    $this->runController($this->getConfigParam('error'),

    Line indented incorrectly; expected at least 24 spaces, found 20
    Open

                        return $_POST[$paramName];

    Line indented incorrectly; expected at least 24 spaces, found 20
    Open

                        return $params[$paramName];

    Closing parenthesis of a multi-line function call must be on a line by itself
    Open

                        ['error' => $ex])

    Line indented incorrectly; expected 20 spaces, found 16
    Open

                    if (($component = $this->getComponent($paramName)) !== null) {

    Opening parenthesis of a multi-line function call must be the last content on the line
    Open

                    $this->runController($this->getConfigParam('error'),

    Line indented incorrectly; expected 20 spaces, found 16
    Open

                    if (isset($_GET[$paramName])) {

    Closing parenthesis of a multi-line function call must be on a line by itself
    Open

                });

    Closing parenthesis of a multi-line function call must be on a line by itself
    Open

                        ['error' => $ex])

    Line indented incorrectly; expected 20 spaces, found 16
    Open

                    }

    Line indented incorrectly; expected 20 spaces, found 16
    Open

                    if (isset($params[$paramName])) {

    Line indented incorrectly; expected 16 spaces, found 12
    Open

                });

    Multi-line function call not indented correctly; expected 12 spaces but found 16
    Open

                    $this->prepareCallback($handler),

    Multi-line function call not indented correctly; expected 12 spaces but found 16
    Open

                    function($paramName) use ($params) {

    Line indented incorrectly; expected at least 24 spaces, found 20
    Open

                        return $component;

    Line indented incorrectly; expected 20 spaces, found 16
    Open

                    }

    Line indented incorrectly; expected 20 spaces, found 16
    Open

                    }

    Closing brace indented incorrectly; expected 16 spaces, found 12
    Open

                });

    Line indented incorrectly; expected at least 24 spaces, found 20
    Open

                        return $_GET[$paramName];

    Multi-line function call not indented correctly; expected 16 spaces but found 20
    Open

                        ['error' => $ex])

    Multi-line function call not indented correctly; expected 16 spaces but found 20
    Open

                        ['error' => $ex])

    Line indented incorrectly; expected 20 spaces, found 16
    Open

                    }

    Closing parenthesis of a multi-line function call must be on a line by itself
    Open

                    500);

    Expected 1 newline at end of file; 0 found
    Open

    }

    There are no issues that match your filters.

    Category
    Status