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