Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid attribute on methods break when read via ReflectionFunction #8982

Closed
nicolas-grekas opened this issue Jul 12, 2022 · 3 comments
Closed

Comments

@nicolas-grekas
Copy link
Contributor

Description

The following code:

#[Attribute(Attribute::TARGET_METHOD)]
class A
{
}

class B
{
    #[A]
    public function m()
    {
    }
}

$a = new B();
$c = [$a, 'm'];
$r = new ReflectionFunction($c(...));
var_dump($r->getAttributes()[0]->newInstance());

Resulted in this output:

Fatal error: Uncaught Error: Attribute "A" cannot target function (allowed targets: method)

But I expected this output instead:

object(A)#5 (0) {
}

PHP Version

PHP >= 8.1.6

Operating System

No response

@cmb69
Copy link
Contributor

cmb69 commented Jul 12, 2022

Indeed: https://3v4l.org/po1ML

@cmb69
Copy link
Contributor

cmb69 commented Jul 12, 2022

The regression has been caused by #8424. @iluuu1994, any ideas on what to do?

@iluuu1994
Copy link
Member

Not off the top of my head. I can look into it next week (I'm on vacation this week).

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

No branches or pull requests

3 participants