1.2.348. Die Exit Consistence

Die and Exit have the same functional use.

The analyzed code has less than 10% of one of them : for consistency reasons, it is recommended to make them all the same.

It happens that die or exit are used depending on coding style and files. One file may be consistently using exit, while the others are all using exit.

Using die or exit is also the target of other analysis.

<?php

// be consistent
switch ($a) {
    case 1 :
        exit;
    case 2 :
        exit;
    case 3 :
        exit;
    case 4 :
        exit;
    case 5 :
        exit;
    case 6 :
        exit;
    case 7 :
        exit;
    case 8 :
        exit;
    case 9 :
        exit;
    case 10 :
        exit;
    default :
        die();   // Be consistent, always use the same.
}

?>

1.2.348.1. Suggestions

  • Adopt one of the two syntaxes

1.2.348.2. Specs

Short name

Structures/DieExitConsistance

Rulesets

All, Preferences

Exakat since

0.8.9

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

die

Available in

Entreprise Edition, Exakat Cloud