-
Notifications
You must be signed in to change notification settings - Fork 2
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
Evaluate methods with short array syntax type hints correctly #8
Conversation
…ay syntax with plain array (e.g. MyClass[] => array)
…ay syntax with plain array (e.g. MyClass[] => array)
I totally agree with your observation but I don't think the scenarios you added describe the behaviour very well. IMHO, if a value matches a type, the fact that the type is returned is not as important as the fact that no exception has been thrown because it contrasts with the non-matching case. So I added these two scenarios instead, one checking that the value is correctly inferred from the hint, the other checking that the type checking works correctly. At that point I noticed that the type checking scenarios should have their own specification and also all follow the pattern of asserting exceptions vs. non-exceptions. So I restructured them. I hope these changes are in your favour. |
If methods had a type hint like "MyClass[]" then the expected result was an instance of "MyClass[]". Instead it should be an array of "MyClass".
This PR contains the following change:
if a type is suffixed with "[]" the type gets replaced by "array" during the parsing phase.
See tests for further details.