020.phpt 489 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. ReflectionObject::hasProperty
  3. --SKIPIF--
  4. <?php extension_loaded('reflection') or die('skip'); ?>
  5. --FILE--
  6. <?php
  7. class Foo {
  8. public $p1;
  9. protected $p2;
  10. private $p3;
  11. function __isset($name) {
  12. var_dump($name);
  13. return false;
  14. }
  15. }
  16. $obj = new ReflectionObject(new Foo());
  17. var_dump($obj->hasProperty("p1"));
  18. var_dump($obj->hasProperty("p2"));
  19. var_dump($obj->hasProperty("p3"));
  20. var_dump($obj->hasProperty("p4"));
  21. ?>
  22. --EXPECT--
  23. bool(true)
  24. bool(true)
  25. bool(true)
  26. bool(false)