YetiForceCompany/YetiForceCRM

View on GitHub
app/Session/Base.php

Summary

Maintainability
A
0 mins
Test Coverage
D
66%

__construct accesses the super-global variable $_SERVER.
Open

    public function __construct(string $name = 'YTSID')
    {
        if (PHP_SESSION_ACTIVE === session_status()) {
            return;
        }
Severity: Minor
Found in app/Session/Base.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

has accesses the super-global variable $_SESSION.
Open

    public function has($key)
    {
        return isset($_SESSION[$key]);
    }
Severity: Minor
Found in app/Session/Base.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

delete accesses the super-global variable $_SESSION.
Open

    public function delete($key)
    {
        unset($_SESSION[$key]);
    }
Severity: Minor
Found in app/Session/Base.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 $_SERVER.
Open

    public function __construct(string $name = 'YTSID')
    {
        if (PHP_SESSION_ACTIVE === session_status()) {
            return;
        }
Severity: Minor
Found in app/Session/Base.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

get accesses the super-global variable $_SESSION.
Open

    public function get($key)
    {
        return $_SESSION[$key] ?? null;
    }
Severity: Minor
Found in app/Session/Base.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

set accesses the super-global variable $_SESSION.
Open

    public function set($key, $value)
    {
        $_SESSION[$key] = $value;
    }
Severity: Minor
Found in app/Session/Base.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

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

    public function regenerateId($deleteOldSession = false)
Severity: Minor
Found in app/Session/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

Avoid using static access to class '\App\RequestUtil' in method '__construct'.
Open

        $cookie['secure'] = \App\RequestUtil::isHttps();
Severity: Minor
Found in app/Session/Base.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 unused parameters such as '$sessionId'.
Open

    public function getById(string $sessionId): array
Severity: Minor
Found in app/Session/Base.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Argument 1 (lifetime) is array|array{domain:false|string}|array{httponly:true}|array{lifetime:0|int}|array{samesite:string}|array{secure:bool} but \session_set_cookie_params() takes int
Open

        session_set_cookie_params($cookie);
Severity: Minor
Found in app/Session/Base.php by phan

Method \App\Session\Base::clean is declared to return string[] but has no return value
Open

    public static function clean()
Severity: Minor
Found in app/Session/Base.php by phan

Method \App\Session\Base::set is declared to return \App\Session\Base|static but has no return value
Open

    public function set($key, $value)
Severity: Minor
Found in app/Session/Base.php by phan

Spaces must be used to indent lines; tabs are not allowed
Open

    public function __construct(string $name = 'YTSID')
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $cookie['domain'] = strtok($_SERVER['HTTP_HOST'], ':');
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (isset(\Config\Security::$cookieForceHttpOnly)) {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $cookie['samesite'] = \Config\Security::$cookieSameSite;
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        session_set_cookie_params($cookie);
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $key
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to remove the value.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $cookie = session_get_cookie_params();
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($cookie['secure']) {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function get($key)
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function set($key, $value)
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $key
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function isSupported()
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return $this
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to check if the key exists.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Is driver available.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $name
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param mixed  $value
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $key
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return true;
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Construct.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        session_name($name);
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $_SESSION[$key] = $value;
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $cookie['secure'] = \App\RequestUtil::isHttps();
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $cookie['httponly'] = \Config\Security::$cookieForceHttpOnly;
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $_SESSION[$key] ?? null;
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return session_regenerate_id($deleteOldSession);
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function has($key)
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return isset($_SESSION[$key]);
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        unset($_SESSION[$key]);
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (PHP_SESSION_ACTIVE === session_status()) {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string[]
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get the value for a given key.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return mixed Value for the given key
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $key
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @see https://php.net/manual/en/function.session-regenerate-id.php
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool $deleteOldSession
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get session data by id.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return 0;
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to set the value for a given key.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            return;
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $cookie['lifetime'] = \Config\Security::$maxLifetimeSessionCookie ?? 0;
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (isset($_SERVER['HTTP_HOST'])) {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Update the current session id with a newly generated one.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return [];
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function cleanAll(): int
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to clean all session.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return int
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function regenerateId($deleteOldSession = false)
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function clean()
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function delete($key)
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $sessionId
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getById(string $sessionId): array
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to clean session. Removed old session.
Severity: Minor
Found in app/Session/Base.php by phpcodesniffer

There are no issues that match your filters.

Category
Status