bug70730.phpt 773 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Bug #70730 (Incorrect ArrayObject serialization if unset is called in serialize())
  3. --FILE--
  4. <?php
  5. class A extends \ArrayObject
  6. {
  7. protected $foo;
  8. public function __construct()
  9. {
  10. $this->foo = 'bar';
  11. }
  12. public function serialize(): string
  13. {
  14. unset($this->foo);
  15. $result = parent::serialize();
  16. $this->foo = 'bar';
  17. return $result;
  18. }
  19. }
  20. $a = new A();
  21. $a->append('item1');
  22. $a->append('item2');
  23. $a->append('item3');
  24. $b = new A();
  25. $b->unserialize($a->serialize());
  26. var_dump($b);
  27. ?>
  28. --EXPECTF--
  29. object(A)#%d (2) {
  30. ["foo":protected]=>
  31. string(3) "bar"
  32. ["storage":"ArrayObject":private]=>
  33. array(3) {
  34. [0]=>
  35. string(5) "item1"
  36. [1]=>
  37. string(5) "item2"
  38. [2]=>
  39. string(5) "item3"
  40. }
  41. }