YetiForceCompany/YetiForceCRM

View on GitHub
include/RequirementsValidation.php

Summary

Maintainability
A
0 mins
Test Coverage
B
80%

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

            throw new \Exception("The {$extension} library is missing");

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('Wrong PHP version, recommended version >= 7.4');

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

        }

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

    }

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

    $extensions = get_loaded_extensions();

Line exceeds 120 characters; contains 145 characters
Open

    foreach (['PDO', 'pdo_mysql', 'json', 'session', 'mbstring', 'fileinfo', 'intl', 'SPL', 'Reflection', 'SimpleXML', 'bcmath'] as $extension) {

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

        if (!\in_array($extension, $extensions)) {

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

            throw new \Exception("The {$extension} library is missing");

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

    foreach (['PDO', 'pdo_mysql', 'json', 'session', 'mbstring', 'fileinfo', 'intl', 'SPL', 'Reflection', 'SimpleXML', 'bcmath'] as $extension) {

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

    throw new \Exception('Wrong PHP version, recommended version >= 7.4');

There are no issues that match your filters.

Category
Status