iranianpep/code-jetter

View on GitHub
core/FormHandler.php

Summary

Maintainability
A
0 mins
Test Coverage

checkAntiCSRF accesses the super-global variable $_SESSION.
Open

    public function checkAntiCSRF($token, $resetAfterChecking = false)
    {
        $output = new Output();

        if (!empty($token)
Severity: Minor
Found in core/FormHandler.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

setAntiCSRF accesses the super-global variable $_SESSION.
Open

    public function setAntiCSRF($hashAlgorithm = null)
    {
        /**
         * start getting a new token.
         */
Severity: Minor
Found in core/FormHandler.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

setAntiCSRF accesses the super-global variable $_SESSION.
Open

    public function setAntiCSRF($hashAlgorithm = null)
    {
        /**
         * start getting a new token.
         */
Severity: Minor
Found in core/FormHandler.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

checkAntiCSRF accesses the super-global variable $_SESSION.
Open

    public function checkAntiCSRF($token, $resetAfterChecking = false)
    {
        $output = new Output();

        if (!empty($token)
Severity: Minor
Found in core/FormHandler.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

checkAntiCSRF accesses the super-global variable $_SESSION.
Open

    public function checkAntiCSRF($token, $resetAfterChecking = false)
    {
        $output = new Output();

        if (!empty($token)
Severity: Minor
Found in core/FormHandler.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

setAntiCSRF accesses the super-global variable $_SESSION.
Open

    public function setAntiCSRF($hashAlgorithm = null)
    {
        /**
         * start getting a new token.
         */
Severity: Minor
Found in core/FormHandler.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

setAntiCSRF accesses the super-global variable $_SESSION.
Open

    public function setAntiCSRF($hashAlgorithm = null)
    {
        /**
         * start getting a new token.
         */
Severity: Minor
Found in core/FormHandler.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

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

                throw new \Exception('Mode is not valid');
Severity: Minor
Found in core/FormHandler.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 checkAntiCSRF has a boolean flag argument $resetAfterChecking, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function checkAntiCSRF($token, $resetAfterChecking = false)
Severity: Minor
Found in core/FormHandler.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

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

        } else {
            $output->setSuccess(false);
        }
Severity: Minor
Found in core/FormHandler.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

Avoid using static access to class 'CodeJetter\core\App' in method 'generateAntiCSRFHtml'.
Open

                $app = App::getInstance();
Severity: Minor
Found in core/FormHandler.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

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 15 and the first side effect is on line 9.
Open

<?php
Severity: Minor
Found in core/FormHandler.php by phpcodesniffer

Avoid variables with short names like $id. Configured minimum length is 3.
Open

    public function generateAntiCSRFHtml($hashAlgorithm = null, $name = null, $id = null, $mode = 'global')
Severity: Minor
Found in core/FormHandler.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

There are no issues that match your filters.

Category
Status