ReflectionProperty_basic2.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. --TEST--
  2. Test usage of ReflectionProperty methods isDefault(), getModifiers(), getDeclaringClass() and getDocComment().
  3. --INI--
  4. opcache.save_comments=1
  5. opcache.load_comments=1
  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 "isDefault():\n";
  13. var_dump($propInfo->isDefault());
  14. echo "getModifiers():\n";
  15. var_dump($propInfo->getModifiers());
  16. echo "getDeclaringClass():\n";
  17. var_dump($propInfo->getDeclaringClass());
  18. echo "getDocComment():\n";
  19. var_dump($propInfo->getDocComment());
  20. echo "\n**********************************\n";
  21. }
  22. class TestClass {
  23. public $pub;
  24. static public $stat = "static property";
  25. /**
  26. * This property has a comment.
  27. */
  28. protected $prot = 4;
  29. private $priv = "keepOut";
  30. }
  31. reflectProperty("TestClass", "pub");
  32. reflectProperty("TestClass", "stat");
  33. reflectProperty("TestClass", "prot");
  34. reflectProperty("TestClass", "priv");
  35. ?>
  36. --EXPECTF--
  37. **********************************
  38. Reflecting on property TestClass::pub
  39. isDefault():
  40. bool(true)
  41. getModifiers():
  42. int(256)
  43. getDeclaringClass():
  44. object(ReflectionClass)#%d (1) {
  45. ["name"]=>
  46. string(9) "TestClass"
  47. }
  48. getDocComment():
  49. bool(false)
  50. **********************************
  51. **********************************
  52. Reflecting on property TestClass::stat
  53. isDefault():
  54. bool(true)
  55. getModifiers():
  56. int(257)
  57. getDeclaringClass():
  58. object(ReflectionClass)#%d (1) {
  59. ["name"]=>
  60. string(9) "TestClass"
  61. }
  62. getDocComment():
  63. bool(false)
  64. **********************************
  65. **********************************
  66. Reflecting on property TestClass::prot
  67. isDefault():
  68. bool(true)
  69. getModifiers():
  70. int(512)
  71. getDeclaringClass():
  72. object(ReflectionClass)#%d (1) {
  73. ["name"]=>
  74. string(9) "TestClass"
  75. }
  76. getDocComment():
  77. string(%d) "/**
  78. * This property has a comment.
  79. */"
  80. **********************************
  81. **********************************
  82. Reflecting on property TestClass::priv
  83. isDefault():
  84. bool(true)
  85. getModifiers():
  86. int(1024)
  87. getDeclaringClass():
  88. object(ReflectionClass)#%d (1) {
  89. ["name"]=>
  90. string(9) "TestClass"
  91. }
  92. getDocComment():
  93. bool(false)
  94. **********************************