xref: /PHP-5.4/ext/reflection/tests/bug46064.phpt (revision 54ba44da)
1--TEST--
2Bug #46064 (Exception when creating ReflectionProperty object on dynamicly created property)
3--FILE--
4<?php
5
6class x {
7	public $zzz = 2;
8}
9
10$o = new x;
11$o->z = 1000;
12$o->zzz = 3;
13
14var_dump($h = new reflectionproperty($o, 'z'));
15var_dump($h->isDefault());
16var_dump($h->isPublic());
17var_dump($h->isStatic());
18var_dump($h->getName());
19var_dump(Reflection::getModifierNames($h->getModifiers()));
20var_dump($h->getValue($o));
21
22print "---------------------------\n";
23try {
24	var_dump(new reflectionproperty($o, 'zz'));
25} catch (Exception $e) {
26	var_dump($e->getMessage());
27}
28
29var_dump(new reflectionproperty($o, 'zzz'));
30
31class test {
32	protected $a = 1;
33}
34
35class bar extends test {
36	public function __construct() {
37		$this->foobar = 2;
38		$this->a = 200;
39
40		$p = new reflectionproperty($this, 'foobar');
41		var_dump($p->getValue($this), $p->isDefault(), $p->isPublic());
42	}
43}
44
45new bar;
46
47?>
48===DONE===
49--EXPECTF--
50object(ReflectionProperty)#%d (2) {
51  ["name"]=>
52  string(1) "z"
53  ["class"]=>
54  string(1) "x"
55}
56bool(false)
57bool(true)
58bool(false)
59string(1) "z"
60array(1) {
61  [0]=>
62  string(6) "public"
63}
64int(1000)
65---------------------------
66string(30) "Property x::$zz does not exist"
67object(ReflectionProperty)#%d (2) {
68  ["name"]=>
69  string(3) "zzz"
70  ["class"]=>
71  string(1) "x"
72}
73int(2)
74bool(false)
75bool(true)
76===DONE===
77