xref: /PHP-7.4/Zend/tests/bug39449.phpt (revision 610c7fbe)
1--TEST--
2Bug #39449 (Overloaded array properties do not work correctly)
3--FILE--
4<?php
5class A {
6  private $keys = array();
7  public function & __get($val) {
8    return $this->keys[$val];
9  }
10  public function __set($k, $v) {
11    $this->keys[$k] = $v;
12  }
13}
14
15$a =new A();
16$a->arr = array('a','b','c');
17
18$b = &$a->arr;
19$b[]= 'd';
20
21foreach ($a->arr as $k => $v) {
22  echo "$k => $v\n";
23}
24
25$a->arr[]='d';
26
27foreach ($a->arr as $k => $v) {
28  echo "$k => $v\n";
29}
30?>
31--EXPECT--
320 => a
331 => b
342 => c
353 => d
360 => a
371 => b
382 => c
393 => d
404 => d
41