| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 21 | public function generateForException(\Exception $exception) |
||
| 22 | { |
||
| 23 | if ($exception instanceof \Vaimo\ComposerPatches\Exceptions\ApplierFailure) { |
||
| 24 | $messages = array_filter($exception->getErrors()); |
||
| 25 | |||
| 26 | if (!$messages) { |
||
|
|
|||
| 27 | return; |
||
| 28 | } |
||
| 29 | |||
| 30 | $lines = array( |
||
| 31 | 'Most likely causes for the failure:', |
||
| 32 | '' |
||
| 33 | ); |
||
| 34 | |||
| 35 | foreach ($messages as $type => $errors) { |
||
| 36 | $lines[] = sprintf('* %s: %s', $type, reset($errors)); |
||
| 37 | } |
||
| 38 | |||
| 39 | $lines = array_merge($lines, array( |
||
| 40 | '', |
||
| 41 | '(For full, unfiltered details please use: composer patch:apply -vvv)' |
||
| 42 | )); |
||
| 43 | |||
| 44 | $this->logger->writeNotice('warning', $lines); |
||
| 45 | } |
||
| 48 |
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.