| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | function cond(array $pairs): \Closure |
||
| 18 | { |
||
| 19 | 2 | if ([] === $pairs) { |
|
| 20 | 1 | throw new CondClauseException; |
|
| 21 | } |
||
| 22 | |||
| 23 | 2 | [$if, $then] = head($pairs); |
|
| 24 | |||
| 25 | $else = function ($x) use ($pairs) { |
||
| 26 | 2 | return cond(tail($pairs))($x); |
|
| 27 | 2 | }; |
|
| 28 | |||
| 29 | 2 | return ifElse($if) |
|
| 30 | 2 | ($then) |
|
| 31 | 2 | ($else); |
|
| 32 | } |
||
| 33 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.