BaguettePHP/mastodon-api

View on GitHub
sample/inc/app.php

Summary

Maintainability
A
1 hr
Test Coverage

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

gc_session accesses the super-global variable $_SESSION.
Open

    function gc_session()
    {
        $now = time();

        $_SESSION['login'] = isset($_SESSION['login']) ? $_SESSION['login'] : [];
Severity: Minor
Found in sample/inc/app.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

Method get_client_app has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function get_client_app(m\Client $client, m\Service\Scope $scope, array $callback_uris)
    {
        $file = strtr($client->getHostname(), ['/' => '_']);
        $path = __DIR__ . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, ['..', 'cache', "{$file}.json"]);

Severity: Minor
Found in sample/inc/app.php - About 1 hr to fix

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

            } else {
                $create_app_path = sprintf('%s://%s/api/v1/apps', $client->getScheme(), $client->getHostname());
                $request_options = [
                    'form_params' => [
                        'client_name' => \SERVICE_NAME . " ip",
    Severity: Minor
    Found in sample/inc/app.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

    Call to undeclared function \GuzzleHttp\json_decode() (Did you mean \json_decode() or \json_encode())
    Open

            return \GuzzleHttp\json_decode($app, true);
    Severity: Critical
    Found in sample/inc/app.php by phan

    Saw possibly unextractable annotation for a fragment of comment '* @param string': after string, did not see an element name (will guess based on comment order)
    Open

         * @param  string
    Severity: Info
    Found in sample/inc/app.php by phan

    Call to method request from undeclared class \GuzzleHttp\ClientInterface
    Open

                $response = m\http()->request('POST', $create_app_path, $request_options);
    Severity: Critical
    Found in sample/inc/app.php by phan

    Possibly zero references to use statement for classlike/namespace v (\Respect\Validation\Validator)
    Open

        use Respect\Validation\Validator as v;
    Severity: Minor
    Found in sample/inc/app.php by phan

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

                app_log()->debug('create_app', ['app' => $app]);
    Severity: Critical
    Found in sample/inc/app.php by phan

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

                chrome_log()->info('request', [
    Severity: Critical
    Found in sample/inc/app.php by phan

    There are no issues that match your filters.

    Category
    Status