1--TEST--
2Dynamic class constant fetch
3--FILE--
4<?php
5
6class FooParent {
7    public const BAR = 'bar';
8    public const BAZ = 'baz';
9}
10
11class Foo extends FooParent {
12    public const BAZ = 'baz child';
13}
14
15class BarParent {
16    public const BAR = 'bar 2';
17    public const BAZ = 'baz 2';
18}
19
20class Bar extends BarParent {
21    public const BAZ = 'baz 2 child';
22}
23
24function test($const) {
25    echo Foo::{$const}, "\n";
26    $foo = 'Foo';
27    echo $foo::{$const}, "\n";
28}
29
30test('BAR');
31test('BAZ');
32
33$c = function ($const) {
34    echo self::{$const}, "\n";
35    echo static::{$const}, "\n";
36    echo parent::{$const}, "\n";
37};
38
39$c->bindTo(null, Foo::class)('BAR');
40$c->bindTo(null, Bar::class)('BAZ');
41$c->bindTo(null, Foo::class)('class');
42$c->bindTo(null, Bar::class)('class');
43
44?>
45--EXPECT--
46bar
47bar
48baz child
49baz child
50bar
51bar
52bar
53baz 2 child
54baz 2 child
55baz 2
56Foo
57Foo
58FooParent
59Bar
60Bar
61BarParent
62