YetiForceCompany/YetiForceCRM

View on GitHub
cli.php

Summary

Maintainability
A
0 mins
Test Coverage
F
31%

Argument 1 (error_handler) is Closure(mixed,mixed,mixed,mixed):void but \set_error_handler() takes callable(int,string):bool|callable(int,string,string):bool|callable(int,string,string,int):bool|callable(int,string,string,int,array):bool|null
Open

set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
Severity: Minor
Found in cli.php by phan

Either remove this useless object instantiation of class "\App\Cli" or use it
Open

    new \App\Cli();
Severity: Major
Found in cli.php by sonar-php

There is no good reason to create a new object to not do anything with it. Most of the time, this is due to a missing piece of code and so could lead to an unexpected behavior in production.

If it was done on purpose because the constructor has side-effects, then that side-effect code should be moved into a separate, static method and called directly.

Noncompliant Code Example

if ($x < 0) {
  new foo;  // Noncompliant
}

Compliant Solution

$var = NULL;
if ($x < 0) {
  $var = new foo;
}

Define and throw a dedicated exception instead of using a generic one.
Open

        throw new \Exception($errNo . ': ' . $errStr . ' in ' . $errFile . ', line ' . $errLine);
Severity: Major
Found in cli.php by sonar-php

If you throw a general exception type, such as ErrorException, RuntimeException, or Exception in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle.

Instead, either throw a subtype that already exists in the Standard PHP Library, or create your own type that derives from Exception.

Noncompliant Code Example

throw new Exception();  // Noncompliant

Compliant Solution

throw new InvalidArgumentException();
// or
throw new UnexpectedValueException();

See

Define and throw a dedicated exception instead of using a generic one.
Open

        throw new \Exception('Console access only from the operating system CLI.');
Severity: Major
Found in cli.php by sonar-php

If you throw a general exception type, such as ErrorException, RuntimeException, or Exception in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle.

Instead, either throw a subtype that already exists in the Standard PHP Library, or create your own type that derives from Exception.

Noncompliant Code Example

throw new Exception();  // Noncompliant

Compliant Solution

throw new InvalidArgumentException();
// or
throw new UnexpectedValueException();

See

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

    require __DIR__ . '/include/RequirementsValidation.php';
Severity: Minor
Found in cli.php by phpcodesniffer

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

    echo "Examples:\nphp74 cli.php\n/usr/local/php74/bin/php74 cli.php\n/usr/local/php80/bin/php80 cli.php\n";
Severity: Minor
Found in cli.php by phpcodesniffer

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

    echo str_repeat('--', 40) . PHP_EOL;
Severity: Minor
Found in cli.php by phpcodesniffer

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

    }
Severity: Minor
Found in cli.php by phpcodesniffer

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

    }
Severity: Minor
Found in cli.php by phpcodesniffer

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

    echo str_repeat('--', 40) . PHP_EOL;
Severity: Minor
Found in cli.php by phpcodesniffer

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

    return;
Severity: Minor
Found in cli.php by phpcodesniffer

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

    echo str_repeat('--', 40) . PHP_EOL;
Severity: Minor
Found in cli.php by phpcodesniffer

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

    new \App\Cli();
Severity: Minor
Found in cli.php by phpcodesniffer

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

    if ('test' === \App\Config::main('systemMode')) {
Severity: Minor
Found in cli.php by phpcodesniffer

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

    echo $th->getMessage() . PHP_EOL;
Severity: Minor
Found in cli.php by phpcodesniffer

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

        throw new \Exception($errNo . ': ' . $errStr . ' in ' . $errFile . ', line ' . $errLine);
Severity: Minor
Found in cli.php by phpcodesniffer

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

    if (\in_array($errNo, [E_ERROR, E_WARNING, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR])) {
Severity: Minor
Found in cli.php by phpcodesniffer

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

    if (PHP_SAPI !== 'cli') {
Severity: Minor
Found in cli.php by phpcodesniffer

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

        throw new \Exception('Console access only from the operating system CLI.');
Severity: Minor
Found in cli.php by phpcodesniffer

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

    echo rtrim(str_replace(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR, '', $e->__toString()), PHP_EOL);
Severity: Minor
Found in cli.php by phpcodesniffer

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

        throw $e;
Severity: Minor
Found in cli.php by phpcodesniffer

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

    }
Severity: Minor
Found in cli.php by phpcodesniffer

There are no issues that match your filters.

Category
Status