YetiForceCompany/YetiForceCRM

View on GitHub
app/ErrorHandler.php

Summary

Maintainability
A
0 mins
Test Coverage
F
29%

Avoid using static access to class '\App\Config' in method 'errorHandler'.
Open

        if (\App\Config::debug('EXCEPTION_ERROR_TO_FILE')) {
Severity: Minor
Found in app/ErrorHandler.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 using static access to class '\App\Config' in method 'errorHandler'.
Open

        if (\App\Config::debug('EXCEPTION_ERROR_TO_SHOW')) {
Severity: Minor
Found in app/ErrorHandler.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 using static access to class '\vtlib\Functions' in method 'errorHandler'.
Open

            \vtlib\Functions::throwNewException($msg, false);
Severity: Minor
Found in app/ErrorHandler.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 using static access to class '\App\Debuger' in method 'errorHandler'.
Open

            $content = print_r($msg, true) . PHP_EOL . \App\Debuger::getBacktrace(2) . PHP_EOL;
Severity: Minor
Found in app/ErrorHandler.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 using static access to class '\App\Config' in method 'init'.
Open

        set_error_handler([__CLASS__, 'errorHandler'], \App\Config::debug('EXCEPTION_ERROR_LEVEL'));
Severity: Minor
Found in app/ErrorHandler.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

Replace this function name "errorHandler" with "__construct".
Open

    public static function errorHandler(int $no, string $str, string $file, int $line): void
Severity: Major
Found in app/ErrorHandler.php by sonar-php

In PHP 4, any function with the same name as the nesting class was considered a class constructor. In PHP 5, this mechanism has been deprecated and the "__construct" method name should be used instead. If both styles are present in the same class, PHP 5 will treat the function named "__construct" as the class constructor.

This rule rule raises an issue for each method with the same name as the enclosing class.

Noncompliant Code Example

class Foo {
  function Foo(){...}
}

Compliant Solution

class Foo {
  function __construct(){...}
}

Avoid variables with short names like $no. Configured minimum length is 3.
Open

    public static function errorHandler(int $no, string $str, string $file, int $line): void
Severity: Minor
Found in app/ErrorHandler.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

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

     * @var string[]
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_PARSE => 'E_PARSE',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

    public static function init(): void
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        register_shutdown_function([__CLASS__, 'fatalHandler']);
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_CORE_WARNING => 'E_CORE_WARNING',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_USER_ERROR => 'E_USER_ERROR',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

     * PHP error handler function.
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

    private static $levelNames = [
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_STRICT => 'E_STRICT',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_CORE_ERROR => 'E_CORE_ERROR',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

Line exceeds 120 characters; contains 151 characters
Open

        if (isset($error['type']) && \in_array($error['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING])) {
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_COMPILE_WARNING => 'E_COMPILE_WARNING',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_USER_WARNING => 'E_USER_WARNING',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

     * @return void
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

     * @param int    $no
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_ERROR => 'E_ERROR',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

     * @see https://secure.php.net/manual/en/function.set-error-handler.php
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_NOTICE => 'E_NOTICE',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

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

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

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

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

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

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

        if (isset($error['type']) && \in_array($error['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING])) {
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

            static::errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

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

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

        E_USER_NOTICE => 'E_USER_NOTICE',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

     * @param string $str
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        set_error_handler([__CLASS__, 'errorHandler'], \App\Config::debug('EXCEPTION_ERROR_LEVEL'));
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

    ];
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

     * Error init.
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

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

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

     * @param string $file
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

     * @param int    $line
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        E_COMPILE_ERROR => 'E_COMPILE_ERROR',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

        if (\class_exists('rcmail')) {
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

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

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

        E_WARNING => 'E_WARNING',
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

     * @return void
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

     * Errors level.
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

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

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

     * PHP fatal handler function.
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

    public static function fatalHandler(): void
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

        $error = error_get_last();
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

    public static function error2string(int $value): array
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        if (E_ALL == ($value & E_ALL)) {
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

     * @param int $value
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

     * @return void
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

     * Convert error number to string.
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

        return $levels;
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

            $logFile = ROOT_DIRECTORY . '/cache/logs/errors.log';
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

            $value &= ~E_ALL;
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        $errorString = static::error2string($no);
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

            if (($value & $level) == $level) {
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

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

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

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

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

        if (\App\Config::debug('EXCEPTION_ERROR_TO_SHOW')) {
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

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

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

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

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

                $levels[] = $name;
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

        $msg = reset($errorString) . ": $str in $file, line $line";
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        if (\App\Config::debug('EXCEPTION_ERROR_TO_FILE')) {
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

            $content = print_r($msg, true) . PHP_EOL . \App\Debuger::getBacktrace(2) . PHP_EOL;
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

            file_put_contents($logFile, $content, FILE_APPEND);
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

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

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

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

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

            \vtlib\Functions::throwNewException($msg, false);
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

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

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

        $levels = [];
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

    public static function errorHandler(int $no, string $str, string $file, int $line): void
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

            $levels[] = 'E_ALL';
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

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

        foreach (self::$levelNames as $level => $name) {
Severity: Minor
Found in app/ErrorHandler.php by phpcodesniffer

There are no issues that match your filters.

Category
Status