1.2.222. Const With Array¶
The const keyword supports array. This feature was added in PHP 5.6.
The array must be filled with other constants. It may also be build using the ‘+’ operator.
<?php
const PRIMES = [2, 3, 5, 7];
class X {
const TWENTY_THREE = 23;
const MORE_PRIMES = PRIMES + [11, 13, 17, 19];
const EVEN_MORE_PRIMES = self::MORE_PRIMES + [self::TWENTY_THREE];
}
?>
See also Class Constants and Constants Syntax.
1.2.222.1. Connex PHP features¶
1.2.222.1.1. Specs¶
Short name |
Php/ConstWithArray |
Rulesets |
All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55 |
Exakat since |
0.8.4 |
PHP Version |
With PHP 5.5 and more recent |
Severity |
Major |
Time To Fix |
Slow (1 hour) |
Precision |
High |
Available in |