wol-soft/php-json-schema-model-generator-production

View on GitHub

Showing 44 of 44 total issues

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

                    throw new Exception();
Severity: Major
Found in src/Filter/DateTime.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

syntax error, unexpected '->' (T_OBJECT_OPERATOR)
Open

        return $value instanceof BackedEnum ? $value?->value : $value?->value();
Severity: Critical
Found in src/Filter/Enum.php by phan

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

            throw new Exception("Invalid Date Time value \"$value\"", 0, $e);
Severity: Major
Found in src/Filter/DateTime.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("Can't process an empty date value");
Severity: Major
Found in src/Filter/DateTime.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

Severity
Category
Status
Source
Language