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