Closed
Description
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