objects_032.phpt 531 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Covariant return-by-ref constraints
  3. --FILE--
  4. <?php
  5. class A implements ArrayAccess {
  6. public $foo = array();
  7. public function &offsetGet($n) {
  8. return $this->foo[$n];
  9. }
  10. public function offsetSet($n, $v) {
  11. }
  12. public function offsetUnset($n) {
  13. }
  14. public function offsetExists($n) {
  15. }
  16. }
  17. $a = new A;
  18. $a['foo']['bar'] = 2;
  19. var_dump($a);
  20. ?>
  21. ==DONE==
  22. --EXPECT--
  23. object(A)#1 (1) {
  24. ["foo"]=>
  25. array(1) {
  26. ["foo"]=>
  27. array(1) {
  28. ["bar"]=>
  29. int(2)
  30. }
  31. }
  32. }
  33. ==DONE==