1--TEST--
2Test ReflectionProperty::setValue() error cases.
3--FILE--
4<?php
5
6class TestClass {
7    public $pub;
8    public $pub2 = 5;
9    static public $stat = "static property";
10    protected $prot = 4;
11    private $priv = "keepOut";
12}
13
14#[AllowDynamicProperties]
15class AnotherClass {
16}
17
18$instance = new TestClass();
19$instanceWithNoProperties = new AnotherClass();
20$propInfo = new ReflectionProperty('TestClass', 'pub2');
21
22echo "\nProtected property:\n";
23
24$propInfo = new ReflectionProperty('TestClass', 'prot');
25$propInfo->setValue($instance, "NewValue");
26var_dump($propInfo->getValue($instance));
27
28echo "\n\nInstance without property:\n";
29$propInfo = new ReflectionProperty('TestClass', 'pub2');
30var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue"));
31var_dump($instanceWithNoProperties->pub2);
32?>
33--EXPECT--
34Protected property:
35string(8) "NewValue"
36
37
38Instance without property:
39NULL
40string(8) "NewValue"
41