Avoid using static access to class '\App\Config' in method 'errorHandler'. Open
if (\App\Config::debug('EXCEPTION_ERROR_TO_FILE')) {
- Read upRead up
- Exclude checks
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')) {
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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'));
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_PARSE => 'E_PARSE',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function init(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
register_shutdown_function([__CLASS__, 'fatalHandler']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_CORE_WARNING => 'E_CORE_WARNING',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_USER_ERROR => 'E_USER_ERROR',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* PHP error handler function.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $levelNames = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_STRICT => 'E_STRICT',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_CORE_ERROR => 'E_CORE_ERROR',
- Exclude checks
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])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_USER_WARNING => 'E_USER_WARNING',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $no
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_ERROR => 'E_ERROR',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @see https://secure.php.net/manual/en/function.set-error-handler.php
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_NOTICE => 'E_NOTICE',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
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])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_USER_NOTICE => 'E_USER_NOTICE',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $str
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
set_error_handler([__CLASS__, 'errorHandler'], \App\Config::debug('EXCEPTION_ERROR_LEVEL'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Error init.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $file
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $line
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\class_exists('rcmail')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
E_WARNING => 'E_WARNING',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Errors level.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* PHP fatal handler function.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function fatalHandler(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$error = error_get_last();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function error2string(int $value): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (E_ALL == ($value & E_ALL)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Convert error number to string.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $levels;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$logFile = ROOT_DIRECTORY . '/cache/logs/errors.log';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value &= ~E_ALL;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$errorString = static::error2string($no);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (($value & $level) == $level) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Config::debug('EXCEPTION_ERROR_TO_SHOW')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$levels[] = $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$msg = reset($errorString) . ": $str in $file, line $line";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Config::debug('EXCEPTION_ERROR_TO_FILE')) {
- Exclude checks
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;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
file_put_contents($logFile, $content, FILE_APPEND);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\vtlib\Functions::throwNewException($msg, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$levels = [];
- Exclude checks
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
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$levels[] = 'E_ALL';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (self::$levelNames as $level => $name) {
- Exclude checks