BaguettePHP/mastodon-api

View on GitHub
sample/inc/functions.php

Summary

Maintainability
A
0 mins
Test Coverage

set_flash accesses the super-global variable $_SESSION.
Open

function set_flash(array $input)
{
    $has_flash = !isset($_SESSION['_flash']) || !is_array($_SESSION['_flash']);
    $flash = $has_flash ? $_SESSION['_flash'] : [];

Severity: Minor
Found in sample/inc/functions.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_flash accesses the super-global variable $_SESSION.
Open

function set_flash(array $input)
{
    $has_flash = !isset($_SESSION['_flash']) || !is_array($_SESSION['_flash']);
    $flash = $has_flash ? $_SESSION['_flash'] : [];

Severity: Minor
Found in sample/inc/functions.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_flash accesses the super-global variable $_SESSION.
Open

function set_flash(array $input)
{
    $has_flash = !isset($_SESSION['_flash']) || !is_array($_SESSION['_flash']);
    $flash = $has_flash ? $_SESSION['_flash'] : [];

Severity: Minor
Found in sample/inc/functions.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_flash accesses the super-global variable $_SESSION.
Open

function set_flash(array $input)
{
    $has_flash = !isset($_SESSION['_flash']) || !is_array($_SESSION['_flash']);
    $flash = $has_flash ? $_SESSION['_flash'] : [];

Severity: Minor
Found in sample/inc/functions.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 '35', column '19').
Open

        throw new \RuntimeException("Template file not exists: {$tpl_name}");
Severity: Minor
Found in sample/inc/functions.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

Missing class import via use statement (line '120', column '24').
Open

        $logger  = new \Monolog\Logger('');
Severity: Minor
Found in sample/inc/functions.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

Missing class import via use statement (line '39', column '16').
Open

    $var = new variables($data);
Severity: Minor
Found in sample/inc/functions.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

Missing class import via use statement (line '104', column '23').
Open

        $logger = new \Monolog\Logger('');
Severity: Minor
Found in sample/inc/functions.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

Call to method pushHandler from undeclared class \Monolog\Logger
Open

        $logger->pushHandler(new StreamHandler($fp, Logger::INFO, true, null, true));
Severity: Critical
Found in sample/inc/functions.php by phan

Return type of router() is undeclared type \Teto\Routing\Router
Open

function router(Router $router = null)
Severity: Minor
Found in sample/inc/functions.php by phan

Reference to constant INFO from undeclared class \Monolog\Logger
Open

        $logger->pushHandler(new StreamHandler($fp, Logger::INFO, true, null, true));
Severity: Critical
Found in sample/inc/functions.php by phan

Parameter $router has undeclared type ?\Teto\Routing\Router
Open

function router(Router $router = null)
Severity: Minor
Found in sample/inc/functions.php by phan

Return type of app_log() is undeclared type \Monolog\Logger
Open

function app_log()
Severity: Minor
Found in sample/inc/functions.php by phan

Call to method __construct from undeclared class \Monolog\Logger
Open

        $logger  = new \Monolog\Logger('');
Severity: Critical
Found in sample/inc/functions.php by phan

Return type of chrome_log() is undeclared type \Monolog\Logger
Open

function chrome_log()
Severity: Minor
Found in sample/inc/functions.php by phan

Call to method __construct from undeclared class \Monolog\Handler\NoopHandler
Open

        $handler = is_production() ? new NoopHandler : new ChromePHPHandler(Logger::INFO);
Severity: Critical
Found in sample/inc/functions.php by phan

Doc-block of $flash in last_flash is phpdoc param type array which is not a permitted replacement of the nullable param type ?array declared in the signature ('?T' should be documented as 'T|null' or '?T')
Open

 * @param array  $flash
Severity: Minor
Found in sample/inc/functions.php by phan

Doc-block of $router in router is phpdoc param type \Teto\Routing\Router which is not a permitted replacement of the nullable param type ?\Teto\Routing\Router declared in the signature ('?T' should be documented as 'T|null' or '?T')
Open

 * @param  Router $router
Severity: Minor
Found in sample/inc/functions.php by phan

Call to method __construct from undeclared class \Monolog\Handler\ChromePHPHandler
Open

        $handler = is_production() ? new NoopHandler : new ChromePHPHandler(Logger::INFO);
Severity: Critical
Found in sample/inc/functions.php by phan

Call to method __construct from undeclared class \Monolog\Handler\StreamHandler
Open

        $logger->pushHandler(new StreamHandler($fp, Logger::INFO, true, null, true));
Severity: Critical
Found in sample/inc/functions.php by phan

Reference to constant INFO from undeclared class \Monolog\Logger
Open

        $handler = is_production() ? new NoopHandler : new ChromePHPHandler(Logger::INFO);
Severity: Critical
Found in sample/inc/functions.php by phan

Call to method __construct from undeclared class \Monolog\Logger
Open

        $logger = new \Monolog\Logger('');
Severity: Critical
Found in sample/inc/functions.php by phan

Call to method pushHandler from undeclared class \Monolog\Logger
Open

        $logger->pushHandler($handler);
Severity: Critical
Found in sample/inc/functions.php by phan

Avoid using short method names like ::h(). The configured minimum method name length is 3.
Open

function h($input)
{
    return htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
}
Severity: Minor
Found in sample/inc/functions.php by phpmd

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

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

There are no issues that match your filters.

Category
Status