| Conditions | 8 |
| Paths | 10 |
| Total Lines | 35 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | public function scanOutputForFailures($output, $separatorMatcher, array $failureMessages) |
||
| 11 | { |
||
| 12 | $patternsWithResults = array_filter($failureMessages, function ($pattern) use ($output) { |
||
| 13 | return $pattern && preg_match($pattern, $output); |
||
| 14 | }); |
||
| 15 | |||
| 16 | if (!$patternsWithResults) { |
||
|
|
|||
| 17 | return array(); |
||
| 18 | } |
||
| 19 | |||
| 20 | $lines = explode(PHP_EOL, $output); |
||
| 21 | |||
| 22 | $matches = array(); |
||
| 23 | |||
| 24 | foreach ($patternsWithResults as $patternCode => $pattern) { |
||
| 25 | if (!isset($matches[$pattern])) { |
||
| 26 | $matches[$patternCode] = array(); |
||
| 27 | } |
||
| 28 | |||
| 29 | foreach ($lines as $line) { |
||
| 30 | if (preg_match($separatorMatcher, $line)) { |
||
| 31 | $matches[$patternCode][] = $line; |
||
| 32 | |||
| 33 | continue; |
||
| 34 | } |
||
| 35 | |||
| 36 | if (!preg_match($pattern, $line)) { |
||
| 37 | continue; |
||
| 38 | } |
||
| 39 | |||
| 40 | $matches[$patternCode][] = $line; |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | return $matches; |
||
| 45 | } |
||
| 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.