Skip to content

ReflectionFunction::getNamespaceName() is broken for closures with PHP8.4 #16122

Description

@takaram

Description

The following code:

<?php

namespace Foo;

class Bar
{
    public static function testClass(): \Closure
    {
        return function(){};
    }
}

function testFunc(): \Closure
{
    return function(){};
}

var_dump((new \ReflectionFunction(Bar::testClass()))->getNamespaceName());
var_dump((new \ReflectionFunction(testFunc()))->getNamespaceName());

Resulted in this output:

string(12) "{closure:Foo"
string(12) "{closure:Foo"

But I expected this output instead:

string(3) "Foo"
string(3) "Foo"

https://3v4l.org/QjjJK/rfc

PHP Version

PHP 8.4.0RC1

Operating System

No response

Activity

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