Repository navigation
fix(AppFramework): Safely parse parenthesised annotations without equals - #64958
sundeep8967 wants to merge 2 commits into
Conversation
come-nc
left a comment
There was a problem hiding this comment.
Please split the unrelated commit out of this PR.
Otherwise the annotation parsing fix looks fine.
In ControllerMethodReflector::reflect(), parenthesised annotations were unconditionally split on '=', assuming every entry followed a key=value format. For annotations without '=' (such as @SuppressWarnings(PHPMD.X)), exploding without '=' returned a 1-element array, triggering PHP warnings: 'Undefined array key 1'. - Only split on '=' when '=' is present in the annotation element. - Avoid shadowing outer foreach loop variable $key with param key. - Add unit test testGetAnnotationParenthesisedWithoutEquals. Fixes nextcloud#64861 Signed-off-by: sundeep8967 <sundeep8967@gmail.com>
c5890ff to
6f5182a
Compare
|
Thanks for the review @come-nc! Rebased and removed the unrelated commit from this PR — now only contains the annotation parsing fix and its test case. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Summary
In
ControllerMethodReflector::reflect(), parenthesised annotations were unconditionally exploded on'=', assuming every parameter followed akey=valuestructure.For annotations without equals (such as
@SuppressWarnings(PHPMD.CyclomaticComplexity)),explode('=', $annotationValues)returns a 1-element array, emitting PHP warnings:Changes
'='only when'='is present in the annotation element.foreachloop key variable with the inner param key.testGetAnnotationParenthesisedWithoutEqualsinControllerMethodReflectorTest.php.Fixes #64861