bug45622.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. SPL: Bug #45622 (isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PROPS set
  3. --FILE--
  4. <?php
  5. class C extends ArrayObject {
  6. public $p = 'object property';
  7. }
  8. $ao = new C(array('p'=>'array element'));
  9. $ao->setFlags(ArrayObject::ARRAY_AS_PROPS);
  10. echo "\n--> Access the real property:\n";
  11. var_dump(isset($ao->p));
  12. var_dump($ao->p);
  13. echo "\n--> Remove the real property and access the array element:\n";
  14. unset($ao->p);
  15. var_dump(isset($ao->p));
  16. var_dump($ao->p);
  17. echo "\n--> Remove the array element and try access again:\n";
  18. unset($ao->p);
  19. var_dump(isset($ao->p));
  20. var_dump($ao->p);
  21. echo "\n--> Re-add the real property:\n";
  22. $ao->p = 'object property';
  23. var_dump(isset($ao->p));
  24. var_dump($ao->p);
  25. ?>
  26. --EXPECTF--
  27. --> Access the real property:
  28. bool(true)
  29. string(15) "object property"
  30. --> Remove the real property and access the array element:
  31. bool(true)
  32. string(13) "array element"
  33. --> Remove the array element and try access again:
  34. bool(false)
  35. Warning: Undefined array key "p" in %s on line %d
  36. NULL
  37. --> Re-add the real property:
  38. bool(true)
  39. string(15) "object property"