Annotation of embedaddon/php/ext/reflection/tests/bug38465.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #38465 (ReflectionParameter fails on access to self::)
3: --FILE--
4: <?php
5: class Baz {
6: const B = 3;
7: }
8:
9: class Foo {
10: const X = 1;
11: public function x($a = self::X, $b = Baz::B, $c = 99) {}
12: }
13:
14: class Bar extends Foo {
15: const Y = 2;
16: public function y($a = self::Y, $b = Baz::B, $c = 99) {}
17: }
18:
19:
20: echo "From global scope:\n";
21:
22: $clazz = new ReflectionClass('Bar');
23: foreach ($clazz->getMethods() as $method) {
24: foreach ($method->getParameters() as $param) {
25: if ($param->isDefaultValueAvailable()) {
26: echo $method->getDeclaringClass()->getName(), '::', $method->getName(), '($', $param->getName(), ' = ', $param->getDefaultValue(), ")\n";
27: }
28: }
29: }
30:
31: echo "\nFrom class context:\n";
32:
33: class Test {
34: function __construct() {
35: $clazz = new ReflectionClass('Bar');
36: foreach ($clazz->getMethods() as $method) {
37: foreach ($method->getParameters() as $param) {
38: if ($param->isDefaultValueAvailable()) {
39: echo $method->getDeclaringClass()->getName(), '::', $method->getName(), '($', $param->getName(), ' = ', $param->getDefaultValue(), ")\n";
40: }
41: }
42: }
43: }
44: }
45:
46: new Test();
47:
48: ?>
49: --EXPECT--
50: From global scope:
51: Bar::y($a = 2)
52: Bar::y($b = 3)
53: Bar::y($c = 99)
54: Foo::x($a = 1)
55: Foo::x($b = 3)
56: Foo::x($c = 99)
57:
58: From class context:
59: Bar::y($a = 2)
60: Bar::y($b = 3)
61: Bar::y($c = 99)
62: Foo::x($a = 1)
63: Foo::x($b = 3)
64: Foo::x($c = 99)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>