ReflectionProperty_getModifiers.001.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. ReflectionProperty::getModifiers()
  3. --CREDITS--
  4. Robin Fernandes <robinf@php.net>
  5. Steve Seear <stevseea@php.net>
  6. --FILE--
  7. <?php
  8. function reflectProperty($class, $property) {
  9. $propInfo = new ReflectionProperty($class, $property);
  10. echo "**********************************\n";
  11. echo "Reflecting on property $class::$property\n\n";
  12. echo "getModifiers():\n";
  13. var_dump($propInfo->getModifiers());
  14. echo "\n**********************************\n";
  15. }
  16. class TestClass
  17. {
  18. public $pub;
  19. static public $stat = "static property";
  20. /**
  21. * This property has a comment.
  22. */
  23. protected $prot = 4;
  24. private $priv = "keepOut";
  25. }
  26. reflectProperty("TestClass", "pub");
  27. reflectProperty("TestClass", "stat");
  28. reflectProperty("TestClass", "prot");
  29. reflectProperty("TestClass", "priv");
  30. ?>
  31. --EXPECT--
  32. **********************************
  33. Reflecting on property TestClass::pub
  34. getModifiers():
  35. int(1)
  36. **********************************
  37. **********************************
  38. Reflecting on property TestClass::stat
  39. getModifiers():
  40. int(17)
  41. **********************************
  42. **********************************
  43. Reflecting on property TestClass::prot
  44. getModifiers():
  45. int(2)
  46. **********************************
  47. **********************************
  48. Reflecting on property TestClass::priv
  49. getModifiers():
  50. int(4)
  51. **********************************