1.2.479. Forgotten Thrown

This rule reports when an exception is instantiated, but not thrown. Often, this is a case of forgotten throw.

<?php

class MyException extends \Exception { }

if ($error !== false) {
    // This looks like 'throw' was omitted
    new MyException();
}

?>

1.2.479.1. Connex PHP features

1.2.479.1.1. Suggestions

  • Remove the instantiation expression.

  • Add the throw to the new expression.

1.2.479.1.2. Specs

Short name

Exceptions/ForgottenThrown

Rulesets

All, Analyze, Changed Behavior

Exakat since

0.10.2

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

High

Available in

Entreprise Edition, Exakat Cloud