| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function __invoke(ReflectionClass $fromClass, ReflectionClass $toClass) : Changes |
||
| 22 | { |
||
| 23 | $removedAncestors = array_merge( |
||
| 24 | array_diff($fromClass->getParentClassNames(), $toClass->getParentClassNames()), |
||
| 25 | array_diff($fromClass->getInterfaceNames(), $toClass->getInterfaceNames()) |
||
| 26 | ); |
||
| 27 | |||
| 28 | if (! $removedAncestors) { |
||
|
|
|||
| 29 | return Changes::empty(); |
||
| 30 | } |
||
| 31 | |||
| 32 | return Changes::fromList(Change::removed( |
||
| 33 | sprintf( |
||
| 34 | 'These ancestors of %s have been removed: %s', |
||
| 35 | $fromClass->getName(), |
||
| 36 | json_encode($removedAncestors) |
||
| 37 | ), |
||
| 38 | true |
||
| 39 | )); |
||
| 42 |
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.