| Conditions | 5 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public static function dailyTemperatures(array $nums): array |
||
| 10 | { |
||
| 11 | if (empty($nums)) { |
||
| 12 | return []; |
||
| 13 | } |
||
| 14 | $n = count($nums); |
||
| 15 | $ans = array_fill(0, $n, 0); |
||
| 16 | for ($i = 0; $i < $n; $i++) { |
||
| 17 | $curr = $nums[$i]; |
||
| 18 | for ($j = $i + 1; $j < $n; $j++) { |
||
| 19 | if ($nums[$j] > $curr) { |
||
| 20 | $ans[$i] = $j - $i; |
||
| 21 | break; |
||
| 22 | } |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | return $ans; |
||
| 27 | } |
||
| 47 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.