Skip to content

ext/reflection: ReflectionParameter fails to load function with leading \ #22324

Closed

Description

@jorgsowa

Description

The following code:

<?php
function demo(string $arg) {}

$p = new ReflectionParameter("\\demo", 0);
var_dump($p->getName());

$p = new ReflectionParameter("demo", 0);
var_dump($p->getName());

Resulted in this output:

Fatal error: Uncaught ReflectionException: Function \demo() does not exist in /in/a4prG:5
Stack trace:
#0 /in/a4prG(5): ReflectionParameter->__construct('\\demo', 0)
#1 {main}
  thrown in /in/a4prG on line 5

But I expected this output instead:

string(3) "arg"
string(3) "arg"

PHP Version

master

Operating System

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions