-
Notifications
You must be signed in to change notification settings - Fork 97
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
Support generics typed iterables for output types #468
Support generics typed iterables for output types #468
Conversation
Codecov Report
@@ Coverage Diff @@
## master #468 +/- ##
============================================
- Coverage 96.36% 96.34% -0.03%
- Complexity 1631 1635 +4
============================================
Files 146 146
Lines 4100 4103 +3
============================================
+ Hits 3951 3953 +2
- Misses 149 150 +1
Continue to review full report at Codecov.
|
Hey @andrew-demb. Thanks for this. Did you see #321? |
Hey @oojacoboo . That PR doesn't solve the problem. |
Thanks for clarifying @andrew-demb. I think it'd be good to also have a test for the full schema parser, maybe something in |
@oojacoboo I found a fixture controller with different typed methods and added to it new methods with generic types. |
Does it make more sense to handle the generic types in this condition in the if ($innerType instanceof Array_ || $innerType instanceof Iterable_ || $innerType instanceof Mixed_) {~ ... instead of the |
Seems like yes, it will be a more appropriate place. It is a bit clumsy (since inside condition logic will check dock block type for throwing new exception), but another way may require a check for implementation of |
b04673c
to
d64dd61
Compare
@andrew-demb I'm not sure why I can't reply on the thread with your question. But, as for your question, I'm not sure I understand this error |
@oojacoboo phpdoc above method narrow down possible type for input parameter
And method contain specific handing for every type (to generate proper exception message) |
@andrew-demb I see no reason not to expand the phpdoc annotation to support this case. |
The problem was with:
Since it is not necessary, I didn't change the exception message and just allows to bypass the |
a93b394
to
ef841d2
Compare
@andrew-demb I see - thanks. In a case like this, I'd just add support and pretend that it could be reached. Future changes could cause that to be the case. Additionally, this method may be reused in other locations. It's best to write a function to handle the logic of its inputs, irregardless of current call stack flows. |
Thanks for suggestions @oojacoboo What can I do to proceed the PR? |
What happens with the following generic annotations? use Acme\Foo;
@return iterable<int, Foo>
@return \Iterator<string, int>
@return \IteratorAggregate<int, bool>
@return \Traversable<string, Foo> |
They will be all converted to ListOfType with proper value type. I will add unit tests for these cases to track behavior. |
This looks great @andrew-demb. Thanks again for the PR! |
refs: #436
Unfortunately, I'm new to the GraphQLite codebase, so it is hard for me to find a clean implementation (and to know about possible drawbacks of chosen way to handle generic iterables)