-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
implementsInterface() isSubclassOf() method inconsistancies in ReflectionClass #72
Comments
I actually have developed a fix for this, but:
|
Hi, @loren-osborn! Thank you for reporting this issue. Of course, sometimes it can be very hard to emulate original reflection behavior, so I suppose that there are issues in my library. Some of them are important and should be fixed, whereas some of them aren't. So, if you can provide broken PHPUnit test with PR then I'll be happy to review it and merge fix. From what I can see, there is an issue in the |
Could you please check the branch I've added additional checks to make |
It looks like there are a few edge cases you missed, including parent interface of an interface. I'll try to update the gist with a more complete set of tests when I get to work. Unfortunately I don't have time now to make it easy to read. 😕 sorry |
One thing I saw that I did differently in my tests, was that I collected all my library behavior data before including any of my PHP files containing the code I was analyzing. Then I included the code and ran the same tests with the native |
Ok... I updated the the public Gist to the more complete one that I ended up using. The code isn't pretty and would need some heavy refactoring if it wasn't going to be discarded, but it should help you get to a clean-room solution, if you want to do it yourself. Please let me know if this is helpful. |
I'm not sure that this makes for the cleanest code, but I found the easiest way to mimic the native |
I'm finding differences in how
Go\ParserReflection\ReflectionClass
and nativeReflectionClass
behave for methodsimplementsInterface()
andisSubclassOf()
. I'm using some fakery to simulate external file loading, so I would be unsurprised if the issue involves how I'm populating these files, but I don't currently see anything I missing in that regard.This is a couple pages of code, so it's hard to call it a "minimal reproducible test case", but I wrote it to be self-contained, and to demonstrate the issue I'm seeing in my code. I hope my comments are adequate, but I opted for clarity of the output over clarity of the code. This is why I chose to use ANSI color codes to make the issue easier to see.
As far as the issue I'm seeing in my actual codebase, I'm seeing the following behavior:
implementsInterface()
is working as expected.isSubclassOf()
is always returningFALSE
.Here is a gist of the example code I'm using: https://gist.github.com/loren-osborn/b3a80c075ebb3ac6d3e2d8749a23bbe7 :
!!
) are returningFALSE
when they should returnTRUE
...
) background are not throwing an exception that the nativeReflectionClass
method throws. This may or may not be the expected behavior. (I suggest thatGo\ParserReflection\ReflectionClass
should throw an exception as well, but that's my personal opinion.)This is what my output looks like::
The text was updated successfully, but these errors were encountered: