1--TEST-- 2Hooks accept method-targeted attributes 3--FILE-- 4<?php 5 6#[Attribute] 7class A {} 8 9#[Attribute(Attribute::TARGET_METHOD)] 10class B {} 11 12class C { 13 public $prop { 14 #[A] get {} 15 #[B] set {} 16 } 17} 18 19$getAttr = (new ReflectionProperty(C::class, 'prop'))->getHook(PropertyHookType::Get)->getAttributes()[0]; 20var_dump($getAttr->getName()); 21var_dump($getAttr->getArguments()); 22var_dump($getAttr->newInstance()); 23 24$setAttr = (new ReflectionProperty(C::class, 'prop'))->getHook(PropertyHookType::Set)->getAttributes()[0]; 25var_dump($setAttr->getName()); 26var_dump($setAttr->getArguments()); 27var_dump($setAttr->newInstance()); 28 29?> 30--EXPECT-- 31string(1) "A" 32array(0) { 33} 34object(A)#3 (0) { 35} 36string(1) "B" 37array(0) { 38} 39object(B)#5 (0) { 40} 41