php / php/php-src

"internal error" in ReflectionParameter::getDefaultValue on Variable-length argument list

オープン
#12,371 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@ndossche がすでに取り組んでいます。

2023年10月6日 から。

  • #12372 @ndossche による — オープン
Bug Extension: reflection Status: Verified
主要言語
C
スター
40.4k
フォーク
8.1k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

The following code:

<?php
declare(strict_types=1);
function f(...$args){
    echo "see? arguments are optional.\n";
}
f();
$ref = new ReflectionFunction('f');
var_dump($ref->getParameters()[0]->getDefaultValue());

Resulted in this output:

see? arguments are optional.

Fatal error: Uncaught ReflectionException: Internal error: Failed to retrieve the default value in /in/gHhJ2:8
Stack trace:
#0 /in/gHhJ2(8): ReflectionParameter->getDefaultValue()
#1 {main}
  thrown in /in/gHhJ2 on line 8

But I expected this output instead:

see? arguments are optional.
array(0) {
}

3v4l: https://3v4l.org/gHhJ2

PHP Version

8.2.11

Operating System

windows 10

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

まず、提供された PHP 8.2.11 のスニペットを再現し、可変長パラメータに対する ReflectionParameter::getDefaultValue() のエントリーポイントを追跡します。呼び出しで内部エラーが発生しなくなり、期待される空の配列が生成されれば、変更は完了です。リンクされたオープンな pull request により、その作業がすでに進行中であることが示されています。

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

評価

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

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

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