1.2.132. Class Const With Array

This rule lists global and class constant that are defined with an array value. This feature was added in PHP 5.6.

<?php

const MY_ARRAY = array();

class x {
     const MY_OTHER_ARRAY = [1, 2];
}
?>

1.2.132.1. Suggestions

  • Store the array in a variable

  • Upgrade to PHP 7.0 or more recent

1.2.132.2. Specs

Short name

Php/ClassConstWithArray

Rulesets

All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55

Exakat since

0.8.4

PHP Version

With PHP 5.5 and more recent

Severity

Critical

Time To Fix

Slow (1 hour)

Changed Behavior

PHP 5.6 - More

Precision

Very high

Features

constant

Available in

Entreprise Edition, Exakat Cloud