1.2.212. Conditional Structures

Structures that are defined, but only executed conditionally.

It is possible to create conditioned functions, classes, interfaces, traits and enumerations. Constants have to be defined with define() and can’t use the const keyword.

Classes elements, such as methods, can’t be conditional.

<?php

if (!function_exists('array_column')) {
    function array_column($a) {
        // some PHP
    }
}

if (!class_exists('foo')) {
    class foo {

    }
}

?>

1.2.212.1. Suggestions

  • Use different names, and apply autoloader.

1.2.212.2. Specs

Short name

Structures/ConditionalStructures

Rulesets

All

Exakat since

0.8.4

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

conditional-structure

Available in

Entreprise Edition, Exakat Cloud