Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassType::from() resolves too much interfaces #32

MCStreetguy opened this issue Jul 23, 2018 · 0 comments

ClassType::from() resolves too much interfaces #32

MCStreetguy opened this issue Jul 23, 2018 · 0 comments


Copy link

@MCStreetguy MCStreetguy commented Jul 23, 2018

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

  1. Create some class that implements interfaces
class Query implements \ArrayAccess, \Countable, \Iterator
    # ...
  1. Then create a ClassType instance through:
    $class = ClassType::from('MyClass');
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant