mambax7/myconference

View on GitHub
class/Common/session.php

Summary

Maintainability
A
0 mins
Test Coverage

get accesses the super-global variable $_SESSION.
Open

    public function get($name)
    {
        if (isset($_SESSION[$name])) {
            return $_SESSION[$name];
        } else {
Severity: Minor
Found in class/Common/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)
    {
        unset($_SESSION[$name]);
    }
Severity: Minor
Found in class/Common/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

get accesses the super-global variable $_SESSION.
Open

    public function get($name)
    {
        if (isset($_SESSION[$name])) {
            return $_SESSION[$name];
        } else {
Severity: Minor
Found in class/Common/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()
    {
        $_SESSION = [];
        session_destroy();
    }
Severity: Minor
Found in class/Common/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)
    {
        $_SESSION[$name] = $value;
    }
Severity: Minor
Found in class/Common/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

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

    protected function __construct()
    {
        @session_start();
    }
Severity: Minor
Found in class/Common/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

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

        } else {
            return false;
        }
Severity: Minor
Found in class/Common/session.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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class MyconferenceSession
Severity: Minor
Found in class/Common/session.php by phpcodesniffer

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 21.
Open

<?php
Severity: Minor
Found in class/Common/session.php by phpcodesniffer

The variable $_sess is not named in camelCase.
Open

    public static function getInstance()
    {
        static $_sess;
        if (!isset($_sess)) {
            $_sess = new self();
Severity: Minor
Found in class/Common/session.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_sess is not named in camelCase.
Open

    public static function getInstance()
    {
        static $_sess;
        if (!isset($_sess)) {
            $_sess = new self();
Severity: Minor
Found in class/Common/session.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_sess is not named in camelCase.
Open

    public static function getInstance()
    {
        static $_sess;
        if (!isset($_sess)) {
            $_sess = new self();
Severity: Minor
Found in class/Common/session.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status