dereference_013.phpt 536 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Testing array dereferencing on array returned from __call method
  3. --FILE--
  4. <?php
  5. error_reporting(E_ALL);
  6. class foo {
  7. public $x = array(2);
  8. public function __call($x, $y) {
  9. if (count($this->x) == 1) {
  10. $this->x[] = $y[0];
  11. }
  12. return $this->x;
  13. }
  14. }
  15. $foo = new foo;
  16. $x = array(1);
  17. $foo->b($x)[1] = 3;
  18. var_dump($foo->b()[0]);
  19. var_dump($foo->b()[1]);
  20. var_dump($foo->b()[2]);
  21. ?>
  22. --EXPECTF--
  23. int(2)
  24. array(1) {
  25. [0]=>
  26. int(1)
  27. }
  28. Warning: Undefined array key 2 in %s on line %d
  29. NULL