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