Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#64,861 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start in lib/private/AppFramework/Utility/ControllerMethodReflector.php at line 60 and inspect reflect(), focusing on parenthesised annotation values without an equals sign. Confirm that annotations such as @SuppressWarnings(PHPMD.CyclomaticComplexity) no longer log an undefined array key, while key=value annotations continue to be stored correctly.

Written by the indexing model from the issue text.

Description

Version: Nextcloud 35.0.1 (same code on master), PHP 8.5

What happens

Every request to a controller method whose docblock contains a PHPMD suppression like

/**
 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
 */

logs a warning:

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

On our instance with OpenRegister/Pipelinq (which use such suppressions in 130 controller files) this is ~370 log entries a day.

Why

reflect() treats any @Annotation(...) value as a key=value list:

foreach ($splitArray as $annotationValues) {
    [$key, $value] = explode('=', $annotationValues);   // no '=' → only one element

PHPMD.CyclomaticComplexity has no =, so index 1 is undefined. As a side effect the inner $key
also shadows the outer foreach key.

Suggested fix

Only split when there is an =, and use a separate variable name:

foreach ($splitArray as $annotationValues) {
    if (!str_contains($annotationValues, '=')) {
        $this->annotations[$annotation][$annotationValues] = '';
        continue;
    }
    [$paramKey, $paramValue] = explode('=', $annotationValues, 2);
    $this->annotations[$annotation][$paramKey] = $paramValue;
}

Workaround we use meanwhile: a space before the parenthesis (@SuppressWarnings (PHPMD.X)) so the value is
stored as a plain string.

Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 5h
Merged PRs (30d)
735

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextcloud/server

All issues in nextcloud/server

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.