1.2.1220. Try Without Catch

Try may only hold a finally clause, to ensure that some code is always executed, in case of error or not.

This is very rare.

<?php

try {
     $x = doSomething();
} finally {
     if (!isset($x)) {
             $x = 'Error';
     }
}

?>

1.2.1220.1. Specs

Short name

Exceptions/TryNoCatch

Rulesets

All, Changed Behavior, Dump

Exakat since

2.6.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

try, catch, finally

Available in

Entreprise Edition, Exakat Cloud