Skip to content

fix(AppFramework): Safely parse parenthesised annotations without equals - #64958

Open
sundeep8967 wants to merge 2 commits into
nextcloud:masterfrom
sundeep8967:fix/controllermethodreflector-annotation-parentheses
Open

sundeep8967 wants to merge 2 commits into
nextcloud:masterfrom
sundeep8967:fix/controllermethodreflector-annotation-parentheses

Conversation

@sundeep8967

Copy link
Copy Markdown

Summary

In ControllerMethodReflector::reflect(), parenthesised annotations were unconditionally exploded on '=', assuming every parameter followed a key=value structure.

For annotations without equals (such as @SuppressWarnings(PHPMD.CyclomaticComplexity)), explode('=', $annotationValues) returns a 1-element array, emitting PHP warnings:

Undefined array key 1 at lib/private/AppFramework/Utility/ControllerMethodReflector.php#60

Changes

  • Split on '=' only when '=' is present in the annotation element.
  • Avoid shadowing the outer foreach loop key variable with the inner param key.
  • Added unit test testGetAnnotationParenthesisedWithoutEquals in ControllerMethodReflectorTest.php.

Fixes #64861

@sundeep8967
sundeep8967 requested review from a team as code owners September 30, 2026 18:11
@sundeep8967
sundeep8967 requested review from come-nc, icewind1991, kristian-zendato, salmart-dev, skjnldsv and sorbaugh and removed request for a team September 30, 2026 18:11

@come-nc come-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@sundeep8967
sundeep8967 force-pushed the fix/controllermethodreflector-annotation-parentheses branch from c5890ff to 6f5182a Compare October 13, 2026 19:36
@sundeep8967

Copy link
Copy Markdown
Author

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.

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

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.)

@come-nc come-nc added the 3. to review Waiting for reviews label Oct 26, 2026
@come-nc come-nc added this to the Nextcloud 36 milestone Oct 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ControllerMethodReflector emits "Undefined array key 1" for parenthesised annotations without = (e.g. @SuppressWarnings(PHPMD.X))

3 participants