-
-
Notifications
You must be signed in to change notification settings - Fork 147
Description
Version: v3.1.2
Bug Description
When "copying" a class through the static factory method ClassType::from(...), it appears that all parent interfaces are applied, not only the ones directly set on the class.
Steps To Reproduce
- Create some class that implements interfaces
class Query implements \ArrayAccess, \Countable, \Iterator
{
# ...
}
- Then create a
ClassTypeinstance through:
$class = ClassType::from('MyClass'); - Convert it to a string and take a closer look on the result:
class Query implements \ArrayAccess, \Countable, \Iterator, \Traversable
{
# ...
}
Expected Behavior
The instance of ClassType should be exactly the same as the original one.
Instead, it implements the parental interface Traversable which then leads to an E_COMPILE_ERROR, due to the interface beeing implemented twice:
Class Melior\Database\Query\Query cannot implement previously implemented interface Traversable
Possible Solution
I don't got any handy solution on this, but it seems as ReflectionClass doesn't care about whether something has been defined directly in the class or has been inherited from parents.
So gathering the interfaces from the ReflectionClass results in all interfaces and their parents, not just the ones directly named behind implements.