015_property_group.phpt 519 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Attributes can be applied to groups of properties
  3. --FILE--
  4. <?php
  5. class C
  6. {
  7. #[A(1, X)]
  8. public $x, $y;
  9. }
  10. const X = 2;
  11. $rp1 = new ReflectionProperty('C', 'x');
  12. $ra1 = $rp1->getAttributes()[0];
  13. var_dump($ra1->getName(), $ra1->getArguments());
  14. $rp2 = new ReflectionProperty('C', 'y');
  15. $ra2 = $rp2->getAttributes()[0];
  16. var_dump($ra2->getName(), $ra2->getArguments());
  17. ?>
  18. --EXPECT--
  19. string(1) "A"
  20. array(2) {
  21. [0]=>
  22. int(1)
  23. [1]=>
  24. int(2)
  25. }
  26. string(1) "A"
  27. array(2) {
  28. [0]=>
  29. int(1)
  30. [1]=>
  31. int(2)
  32. }