1--TEST--
2Test caching of hooked property
3--FILE--
4<?php
5
6class Test {
7    public $prop {
8        get { echo __METHOD__, "\n"; return $this->prop; }
9        set { echo __METHOD__, "\n"; $this->prop = $value; }
10    }
11}
12
13function doTest(Test $test) {
14    $test->prop = null;
15    $test->prop;
16    $test->prop = 1;
17    $test->prop += 1;
18    $test->prop = [];
19    try {
20        $test->prop[] = 1;
21    } catch (\Error $e) {
22        echo $e->getMessage(), "\n";
23    }
24    isset($test->prop);
25    isset($test->prop[0]);
26    try {
27        unset($test->prop);
28    } catch (Error $e) {
29        echo $e->getMessage(), "\n";
30    }
31}
32
33$test = new Test;
34$test->dyn = 1;
35doTest($test);
36echo "\n";
37doTest($test);
38
39?>
40--EXPECTF--
41Deprecated: Creation of dynamic property Test::$dyn is deprecated in %s on line %d
42Test::$prop::set
43Test::$prop::get
44Test::$prop::set
45Test::$prop::get
46Test::$prop::set
47Test::$prop::set
48Test::$prop::get
49Indirect modification of Test::$prop is not allowed
50Test::$prop::get
51Test::$prop::get
52Cannot unset hooked property Test::$prop
53
54Test::$prop::set
55Test::$prop::get
56Test::$prop::set
57Test::$prop::get
58Test::$prop::set
59Test::$prop::set
60Test::$prop::get
61Indirect modification of Test::$prop is not allowed
62Test::$prop::get
63Test::$prop::get
64Cannot unset hooked property Test::$prop
65