Open ciaranmcnulty opened 9 years ago
hmm, we should indeed sort interfaces when generating the code to avoid this issue. Do you want to work on a fix ?
I might, I have a short list of PhpSpec things to do but if I can see a fix I'll implement,
I triggered this by the following typo in PhpSpec:
function let(Interface $double) {...}
function it_does_something(MoreSpecificInterface $double) { ... }
The matching argument names actually makes the double implement both interfaces, which might also be an error case.
@stof The sorting algorithm is non-trivial I suspect.
@ciaranmcnulty parent before children (and any order for non-related interfaces).
You can see https://github.com/symfony/symfony/blob/4133aadd0c0be199b21ce5e171038e5d03bc818b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php#L242 for some code doing such sorting in a much more complex case (it needs to take parent classes and traits into account as well, and collect them to add them in the list if they were not there yet, which is not necessary here)
You'd also need to take into account what interfaces the classes implement, I think?
The other issue I'd have is lack of unit tests - I guess that's something you'd be open to me introducing to the projects?
lack of unit tests ? Couldn't this be covered by the specs of the classes we already have ?
Ignore me, I was mixing it up with another project (behat) :-)
Reproducible case:
Root cause is that the following code is trying to be
eval()
ed:Which triggers this PHP bug (or rather, 'documented behaviour'): https://bugs.php.net/bug.php?id=63816