1--TEST--
2ReflectionClass::getStaticPropertyValue()
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 "Retrieving static values from A:\n";
23$rcA = new ReflectionClass('A');
24var_dump($rcA->getStaticPropertyValue("privateOverridden", "default value"));
25var_dump($rcA->getStaticPropertyValue("\0A\0privateOverridden"));
26var_dump($rcA->getStaticPropertyValue("protectedOverridden", "default value"));
27var_dump($rcA->getStaticPropertyValue("\0*\0protectedOverridden"));
28var_dump($rcA->getStaticPropertyValue("publicOverridden"));
29
30echo "\nRetrieving static values from B:\n";
31$rcB = new ReflectionClass('B');
32var_dump($rcB->getStaticPropertyValue("\0A\0privateOverridden"));
33var_dump($rcB->getStaticPropertyValue("\0B\0privateOverridden"));
34var_dump($rcB->getStaticPropertyValue("\0*\0protectedOverridden"));
35var_dump($rcB->getStaticPropertyValue("publicOverridden"));
36
37echo "\nRetrieving non-existent values from A with no default value:\n";
38try {
39	var_dump($rcA->getStaticPropertyValue("protectedOverridden"));
40	echo "you should not see this";
41} catch (Exception $e) {
42	echo $e->getMessage() . "\n";
43}
44
45try {
46	var_dump($rcA->getStaticPropertyValue("privateOverridden"));
47	echo "you should not see this";
48} catch (Exception $e) {
49	echo $e->getMessage() . "\n";
50}
51
52?>
53--EXPECTF--
54Retrieving static values from A:
55string(13) "default value"
56string(16) "original private"
57string(13) "default value"
58string(18) "original protected"
59string(15) "original public"
60
61Retrieving static values from B:
62string(16) "original private"
63string(15) "changed private"
64string(17) "changed protected"
65string(14) "changed public"
66
67Retrieving non-existent values from A with no default value:
68Class A does not have a property named protectedOverridden
69Class A does not have a property named privateOverridden
70