1--TEST--
2ReflectionProperty::{get,set}RawValue() does not invoke hooks
3--FILE--
4<?php
5
6class Test {
7    public $publicProp {
8        get {
9            echo __FUNCTION__, "\n";
10            return $this->publicProp;
11        }
12        set {
13            echo __FUNCTION__, "\n";
14            $field = $value;
15        }
16    }
17    public $privateProp {
18        get {
19            echo __FUNCTION__, "\n";
20            return $this->privateProp;
21        }
22        set {
23            echo __FUNCTION__, "\n";
24            $field = $value;
25        }
26    }
27    public $virtualProp {
28        get {
29            echo __FUNCTION__, "\n";
30            return 42;
31        }
32        set {
33            echo __FUNCTION__, "\n";
34        }
35    }
36    private $plainProp;
37
38    public function __get($name) {
39        echo __FUNCTION__, "\n";
40        return 42;
41    }
42}
43
44class Unguarded {
45    private $plainProp;
46}
47
48function test($class, $prop) {
49    $propertyReflection = (new ReflectionProperty($class, $prop));
50    $object = new $class();
51    try {
52        $propertyReflection->setRawValue($object, 42);
53    } catch (Error $e) {
54        echo $e->getMessage(), "\n";
55    }
56    try {
57        var_dump($propertyReflection->getRawValue($object));
58    } catch (Error $e) {
59        echo $e->getMessage(), "\n";
60    }
61}
62
63test(Test::class, 'publicProp');
64test(Test::class, 'privateProp');
65test(Test::class, 'virtualProp');
66test(Test::class, 'plainProp');
67test(Unguarded::class, 'plainProp');
68
69?>
70--EXPECT--
71int(42)
72int(42)
73Must not write to virtual property Test::$virtualProp
74Must not read from virtual property Test::$virtualProp
75int(42)
76int(42)
77