| Conditions | 2 |
| Paths | 2 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function compare(ReflectionClass $fromInterface, ReflectionClass $toInterface) : Changes |
||
| 15 | { |
||
| 16 | $fromMethods = $this->methods($fromInterface); |
||
| 17 | $toMethods = $this->methods($toInterface); |
||
| 18 | $newMethods = array_diff_key($toMethods, $fromMethods); |
||
| 19 | |||
| 20 | if (! $newMethods) { |
||
|
|
|||
| 21 | return Changes::new(); |
||
| 22 | } |
||
| 23 | |||
| 24 | return Changes::fromArray(array_values(array_map(function (ReflectionMethod $method) use ( |
||
| 25 | $fromInterface |
||
| 26 | ) : Change { |
||
| 27 | return Change::added( |
||
| 28 | sprintf( |
||
| 29 | 'Method %s() was added to interface %s', |
||
| 30 | $method->getName(), |
||
| 31 | $fromInterface->getName() |
||
| 32 | ), |
||
| 33 | true |
||
| 34 | ); |
||
| 35 | }, $newMethods))); |
||
| 36 | } |
||
| 51 |
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.