mambax7/publisher

View on GitHub
class/Session.php

Summary

Maintainability
A
0 mins
Test Coverage

get accesses the super-global variable $_SESSION.
Open

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

del accesses the super-global variable $_SESSION.
Open

    public function del($name): void
    {
        unset($_SESSION[$name]);
    }
Severity: Minor
Found in class/Session.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($name, $value): void
    {
        $_SESSION[$name] = $value;
    }
Severity: Minor
Found in class/Session.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

destroy accesses the super-global variable $_SESSION.
Open

    public function destroy(): void
    {
        $_SESSION = [];
        \session_destroy();
    }
Severity: Minor
Found in class/Session.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 '39', column '23').
Open

            throw new \RuntimeException('Session could not start.');
Severity: Minor
Found in class/Session.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

Remove error control operator '@' on line 38.
Open

    protected function __construct()
    {
        if (!@\session_start()) {
            throw new \RuntimeException('Session could not start.');
        }
Severity: Minor
Found in class/Session.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

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

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 28 and the first side effect is on line 23.
Open

<?php declare(strict_types=1);
Severity: Minor
Found in class/Session.php by phpcodesniffer

There are no issues that match your filters.

Category
Status