Skip to content

ReflectionParameter::getDefaultValue() of a default written self::X fails with 'Class "" not found' (evaluated outside the declaring class) #288

Closed

Description

@blacktrs

Summary

ReflectionParameter::getDefaultValue() of a default written self::X fails with 'Class "" not found' (evaluated outside the declaring class).

Repro

<?php
class P {
    const X = 3;
    public function g($x = [1, 2], $y = self::X) {}
}
foreach ((new ReflectionMethod('P', 'g'))->getParameters() as $p) {
    echo $p->getName(), ' = ', json_encode($p->getDefaultValue()), "\n";
}

Expected (php)

x = [1,2]
y = 3

Actual (manticore cecbe162, Darwin arm64)

x = [1,2]
y = 
[exit code 255]
PHP Fatal error:  Uncaught Error: Class "" not found

Tracking

Known-bug repro: tests/aot/repro/wrong/refl_param_default_self_const.php — bash tests/aot/xfail.sh -k refl_param_default_self_const reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions