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

未关闭
#12,371 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@ndossche 已经在做这个了。

开始于 2023年10月6日。

  • #12372 来自 @ndossche —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
c, php
领域
backend

调研方向

首先复现所提供的 PHP 8.2.11 代码片段,并跟踪可变参数的 ReflectionParameter::getDefaultValue() 入口点。当调用不再抛出内部错误并生成预期的空数组时,此更改即完成;一个已关联的开放 pull request 表明这项工作已经在进行中。

由索引模型根据 Issue 内容生成。

描述

Bug Extension: reflection Status: Verified
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

主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 15 小时
30 天内合并 PR
103

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。