- var_dump: documentation ( source)
<?php
#[\Attribute(\Attribute::TARGET_METHOD)]
class TestAttribute {}
class ParentClass {
#[TestAttribute]
function foo() {
}
}
class ChildclassA extends ParentClass {}
class ChildclassB extends ParentClass {
function foo() {
}
}
$method = new \ReflectionMethod(ParentClass::class, 'foo');
var_dump($method->getAttributes(TestAttribute::class));
$method = new \ReflectionMethod(ChildClassA::class, 'foo');
var_dump($method->getAttributes(TestAttribute::class));
$method = new \ReflectionMethod(ChildClassB::class, 'foo');
var_dump($method->getAttributes(TestAttribute::class));