1.2.982. Php7 Relaxed Keyword¶
Most of the traditional PHP keywords may be used inside classes, enums, traits and interfaces: they can be used as constant or method name.
It is recommended to use this syntax cautiously, as it leads to a lot of surprises and confusion from unususpecting developpers.
This was not the case in PHP 5, and will yield parse errors.
<?php
// Compatible with PHP 7.0 +
class foo {
const array = [];
// as is a PHP 5 keyword
public function as() {
print_r(self::array);
}
}
?>
See also Loosening Reserved Word Restrictions.
1.2.982.1. Connex PHP features¶
1.2.982.1.1. Specs¶
Short name |
Php/Php7RelaxedKeyword |
Rulesets |
All, Appinfo, CE, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56 |
Exakat since |
0.8.4 |
PHP Version |
With PHP 7.0 and more recent |
Severity |
Major |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Related rule |
|
Available in |