1.2.764. Nested Match¶
Nested match calls makes the code difficult to read. It is recommended to avoid nesting match calls.
<?php
$a = match($b) {
1 => 3,
3 => 'ab',
5 => match($c) {
6 => new X,
7 => [],
}
default => false,
};
?>
1.2.764.1. Suggestions¶
Merge the two match() in one.
Replace the nested match call by a method call.
1.2.764.2. Specs¶
Short name |
Structures/NestedMatch |
Rulesets |
|
Exakat since |
2.6.5 |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |