1.2.28. Alternative Syntax Consistence

PHP allows for two syntax : the alternative syntax, and the classic syntax.

The classic syntax is almost always used. When used, the alternative syntax is used in templates.

This analysis reports files that are using both syntax at the same time. This is confusing.

<?php

// Mixing both syntax is confusing.
foreach($array as $item) :
    if ($item > 1) {
        print "$item elementsn";
    } else {
        print "$item elementn";
    }
endforeach;

?>

1.2.28.1. Specs

Short name

Structures/AlternativeConsistenceByFile

Rulesets

All, Analyze

Exakat since

0.11.2

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

High

Features

alternative-syntax

Available in

Entreprise Edition, Exakat Cloud