1--TEST--
2ReflectionClass::setStaticPropertyValue()
3--CREDITS--
4Robin Fernandes <robinf@php.net>
5Steve Seear <stevseea@php.net>
6--SKIPIF--
7<?php if (version_compare(zend_version(), '2.4.0', '>=')) die('skip ZendEngine 2.3 or below needed'); ?>
8--FILE--
9<?php
10class A {
11	static private $privateOverridden = "original private";
12	static protected $protectedOverridden = "original protected";
13	static public $publicOverridden = "original public";
14}
15
16class B extends A {
17	static private $privateOverridden = "changed private";
18	static protected $protectedOverridden = "changed protected";
19	static public $publicOverridden = "changed public";
20}
21
22echo "Set static values in A:\n";
23$rcA = new ReflectionClass('A');
24$rcA->setStaticPropertyValue("\0A\0privateOverridden", "new value 1");
25$rcA->setStaticPropertyValue("\0*\0protectedOverridden", "new value 2");
26$rcA->setStaticPropertyValue("publicOverridden", "new value 3");
27print_r($rcA->getStaticProperties());
28
29echo "\nSet static values in B:\n";
30$rcB = new ReflectionClass('B');
31$rcB->setStaticPropertyValue("\0A\0privateOverridden", "new value 4");
32$rcB->setStaticPropertyValue("\0B\0privateOverridden", "new value 5");
33$rcB->setStaticPropertyValue("\0*\0protectedOverridden", "new value 6");
34$rcB->setStaticPropertyValue("publicOverridden", "new value 7");
35print_r($rcA->getStaticProperties());
36print_r($rcB->getStaticProperties());
37
38echo "\nSet non-existent values from A with no default value:\n";
39try {
40	var_dump($rcA->setStaticPropertyValue("protectedOverridden", "new value 8"));
41	echo "you should not see this";
42} catch (Exception $e) {
43	echo $e->getMessage() . "\n";
44}
45
46try {
47	var_dump($rcA->setStaticPropertyValue("privateOverridden", "new value 9"));
48	echo "you should not see this";
49} catch (Exception $e) {
50	echo $e->getMessage() . "\n";
51}
52
53?>
54--EXPECTF--
55Set static values in A:
56Array
57(
58    [privateOverridden] => new value 1
59    [protectedOverridden] => new value 2
60    [publicOverridden] => new value 3
61)
62
63Set static values in B:
64Array
65(
66    [privateOverridden] => new value 4
67    [protectedOverridden] => new value 2
68    [publicOverridden] => new value 3
69)
70Array
71(
72    [privateOverridden] => new value 5
73    [protectedOverridden] => new value 6
74    [publicOverridden] => new value 7
75)
76
77Set non-existent values from A with no default value:
78Class A does not have a property named protectedOverridden
79Class A does not have a property named privateOverridden
80