1.2.1047. Reserved Match Keyword¶
match
is a new instruction in PHP 8.0.
For that, it becomes a reserved keyword, and cannot be used in various situations: type, class, function, global constant name.
<?php
// Match as a standalone keyword is not possible
use X as Match;
// No more use as a type
function foo(match $a ) : match {}
$a instanceof match;
// No use as method name
match(a, 4) ;
// Match in a Fully qualified name is OK
b\match ;
// Match as a property name or a class constant is OK
$match->match;
C::MATCH;
// Match as a method is OK
$method->match();
$static::match();
?>
See also Match expression V2.
1.2.1047.2. Connex PHP features¶
1.2.1047.2.1. Suggestions¶
Change the name from Match to something else.
1.2.1047.2.2. Specs¶
Short name |
Php/ReservedMatchKeyword |
Rulesets |
|
Exakat since |
2.2.1 |
PHP Version |
With PHP 8.0 and older |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Related rule |
|
Available in |