bug34548.phpt 632 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Bug #34548 (Method append() in class extended from ArrayObject crashes PHP)
  3. --FILE--
  4. <?php
  5. class Collection extends ArrayObject
  6. {
  7. public function add($dataArray)
  8. {
  9. foreach($dataArray as $value) $this->append($value);
  10. }
  11. public function offsetSet($index, $value): void
  12. {
  13. parent::offsetSet($index, $value);
  14. }
  15. }
  16. $data1=array('one', 'two', 'three');
  17. $data2=array('four', 'five');
  18. $foo=new Collection($data1);
  19. $foo->add($data2);
  20. print_r($foo->getArrayCopy());
  21. echo "Done\n";
  22. ?>
  23. --EXPECT--
  24. Array
  25. (
  26. [0] => one
  27. [1] => two
  28. [2] => three
  29. [3] => four
  30. [4] => five
  31. )
  32. Done