1.2.79. Bad Constants Names

PHP’s manual recommends that developer do not use constants with the convention __NAME__. Those are reserved for PHP future use.

For example, __TRAIT__ recently appeared in PHP, as a magic constant. In the future, other may appear.

The analyzer will report any constant which name is __.*.__, or even _.*_ (only one underscore).

<?php

const __MY_APP_CONST__ = 1;

const __MY_APP_CONST__ = 1;

define('__MY_OTHER_APP_CONST__', 2);

?>

See also Constants.

1.2.79.1. Suggestions

  • Avoid using names that doesn’t comply with PHP’s convention

1.2.79.2. Specs

Short name

Constants/BadConstantnames

Rulesets

All, Analyze, PHP recommendations

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Slow (1 hour)

Precision

Very high

Features

constant

Examples

PrestaShop, Zencart

Available in

Entreprise Edition, Exakat Cloud