Closed
Description
PHP8 Introduced match()
as a new expression syntax, similar to a switch
statement but with a rather different structure, using an arrow (=>
) to separate the case
from the expression that it would return. This should also be factored into the CYC calculation for the Generic.Metrics.CyclomaticComplexity
sniff.
When calculating the CYC, this should be evaluated like a switch
statement, with each T_MATCH_ARROW
token corresponding to a case
and increasing the CYC by one. There is no need to add one for the T_MATCH_DEFAULT
token, because this is followed by a T_MATCH_ARROW
token, and to do so would be to double-count that entry.
PR to follow.
Metadata
Metadata
Assignees
Labels
No labels