xref: /PHP-7.1/Zend/tests/ns_095.phpt (revision 113213f0)
1--TEST--
2Absolute namespaces should be allowed
3--FILE--
4<?php
5
6namespace Foo\Bar {
7    class ClassA{}
8    class ClassB{}
9    class ClassC{}
10
11    function fn_a(){ return __FUNCTION__; }
12    function fn_b(){ return __FUNCTION__; }
13    function fn_c(){ return __FUNCTION__; }
14
15    const CONST_A = 1;
16    const CONST_B = 2;
17    const CONST_C = 3;
18}
19
20namespace Baz {
21
22    use \Foo\Bar\{ClassA, ClassB, ClassC};
23    use function \Foo\Bar\{fn_a, fn_b, fn_c};
24    use const \Foo\Bar\{CONST_A, CONST_B, CONST_C};
25
26    var_dump(ClassA::class);
27    var_dump(ClassB::class);
28    var_dump(ClassC::class);
29    var_dump(fn_a());
30    var_dump(fn_b());
31    var_dump(fn_c());
32    var_dump(CONST_A);
33    var_dump(CONST_B);
34    var_dump(CONST_C);
35
36    echo "\nDone\n";
37}
38?>
39--EXPECTF--
40string(14) "Foo\Bar\ClassA"
41string(14) "Foo\Bar\ClassB"
42string(14) "Foo\Bar\ClassC"
43string(12) "Foo\Bar\fn_a"
44string(12) "Foo\Bar\fn_b"
45string(12) "Foo\Bar\fn_c"
46int(1)
47int(2)
48int(3)
49
50Done
51