Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#64,861 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
backend

調査の方向性

lib/private/AppFramework/Utility/ControllerMethodReflector.php の 60 行目から始めて reflect() を調べ、等号のない括弧内のアノテーション値に注目してください。@SuppressWarnings(PHPMD.CyclomaticComplexity) のようなアノテーションで未定義の配列キーがログに記録されなくなっていること、また key=value アノテーションが引き続き正しく保存されることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
PHP
スター
36.9k
フォーク
5.2k
平均マージ
2日 5時間
マージ済み PR(30日)
735

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nextcloud/server のほかの issue

nextcloud/server の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。