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.4 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:
56
57Fatal error: Uncaught exception 'ReflectionException' with message 'Class A does not have a property named ' in %sReflectionClass_setStaticPropertyValue_001_2_4.php:%d
58Stack trace:
59#0 %sReflectionClass_setStaticPropertyValue_001_2_4.php(%d): ReflectionClass->setStaticPropertyValue('\x00A\x00privateOverr...', 'new value 1')
60#1 {main}
61  thrown in %sReflectionClass_setStaticPropertyValue_001_2_4.php on line %d
62