-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PHP 8.0 | File::getMethodParameters(): bug fix for attributes leaking into typehint #3320
PHP 8.0 | File::getMethodParameters(): bug fix for attributes leaking into typehint #3320
Conversation
This test demonstrates and documents the existing behaviour of the method when comments are encountered within a parameter declaration.
… hint This commit adds handling of parameter attributes to the `File::getMethodParameters()` method as per option [2] discussed in issue 3298. In practice this means that: * [New] A new `attributes` index is introduced into the returned array which will hold a boolean value indicating whether attributes are attached to the parameter. * [Unchanged] The `content` index in the returned array includes the textual representation of any attributes attached to a parameter. * [Fixed] The `type_hint` and `type_hint_token` indexes will no longer be polluted (set incorrectly) with information belonging to the attribute(s) instead of to the type declaration. Includes minor efficiency fix for handling of parenthesis and brackets in default values. Includes dedicated unit test. Fixes 3298
d01dc4f
to
e3b113f
Compare
Do you think the new array index would be better named "has_attributes" to indicate that it's a boolean? I could make that change once I go to merge this if you agree. |
I'm not fussed about the name either way, but yes, I based the current name |
@gsherwood Shall I otherwise just remove the extra array index key for now ? We can always circle back to that if and when there are explicit requests for it. |
I think it's fine to leave it - the work has been done - but I will likely rename it. I think The actual value of the MR is in the fix itself, but I still think the new index is a nice addition if we can agree on a name. Given you had the exact same naming thought, if you're ok with some inconsistency in the naming (hopefully I explained why I am) then I think the index should stay. |
Thanks a lot for this. I did end up changing the name of the array index to |
File::getMethodParameters(): add test documenting behaviour for comments
This test demonstrates and documents the existing behaviour of the method when comments are encountered within a parameter declaration.
File:;getMethodParameters(): bug fix for attributes leaking into typehint
This commit adds handling of parameter attributes to the
File::getMethodParameters()
method as per option [2] discussed in issue #3298.In practice this means that:
attributes
index is introduced into the returned array which will hold a boolean value indicating whether attributes are attached to the parameter.content
index in the returned array includes the textual representation of any attributes attached to a parameter.type_hint
andtype_hint_token
indexes will no longer be polluted (set incorrectly) with information belonging to the attribute(s) instead of to the type declaration.Includes minor efficiency fix for handling of parenthesis and brackets in default values.
Includes dedicated unit test.
Fixes #3298