1--TEST--
2class name as scalar from ::class keyword
3--FILE--
4<?php
5
6namespace Foo\Bar {
7    class One {
8        // compile time constants
9        const A = self::class;
10        const B = Two::class;
11    }
12    class Two extends One {
13        public static function run() {
14            var_dump(self::class); // self compile time lookup
15            var_dump(static::class); // runtime lookup
16            var_dump(parent::class); // runtime lookup
17            var_dump(Baz::class); // default compile time lookup
18        }
19    }
20    class Three extends Two {
21        // compile time static lookups
22        public static function checkCompileTime(
23            $one = self::class,
24            $two = Baz::class,
25            $three = One::A,
26            $four = self::B
27        ) {
28            var_dump($one, $two, $three, $four);
29        }
30    }
31    echo "In NS\n";
32    var_dump(Moo::CLASS); // resolve in namespace
33}
34
35namespace {
36    use Bee\Bop as Moo,
37        Foo\Bar\One;
38    echo "Top\n";
39    var_dump(One::class); // resolve from use
40    var_dump(Boo::class); // resolve in global namespace
41    var_dump(Moo::CLASS); // resolve from use as
42    var_dump(\Moo::Class); // resolve fully qualified
43    $class = One::class; // assign class as scalar to var
44    $x = new $class; // create new class from original scalar assignment
45    var_dump($x);
46    Foo\Bar\Two::run(); // resolve runtime lookups
47    echo "Parent\n";
48    Foo\Bar\Three::run(); // resolve runtime lookups with inheritance
49    echo "Compile Check\n";
50    Foo\Bar\Three::checkCompileTime();
51}
52
53?>
54--EXPECT--
55In NS
56string(11) "Foo\Bar\Moo"
57Top
58string(11) "Foo\Bar\One"
59string(3) "Boo"
60string(7) "Bee\Bop"
61string(3) "Moo"
62object(Foo\Bar\One)#1 (0) {
63}
64string(11) "Foo\Bar\Two"
65string(11) "Foo\Bar\Two"
66string(11) "Foo\Bar\One"
67string(11) "Foo\Bar\Baz"
68Parent
69string(11) "Foo\Bar\Two"
70string(13) "Foo\Bar\Three"
71string(11) "Foo\Bar\One"
72string(11) "Foo\Bar\Baz"
73Compile Check
74string(13) "Foo\Bar\Three"
75string(11) "Foo\Bar\Baz"
76string(11) "Foo\Bar\One"
77string(11) "Foo\Bar\Two"
78