xref: /PHP-7.2/Zend/tests/ns_092.phpt (revision f1d7e3ca)
1--TEST--
2Typed group use statements
3--FILE--
4<?php
5namespace Foo\Bar {
6    class A { function __construct() {echo __METHOD__,"\n";} }
7    class B { function __construct() {echo __METHOD__,"\n";} }
8    function fiz(){ echo __FUNCTION__,"\n"; }
9    function biz(){ echo __FUNCTION__,"\n"; }
10    function buz(){ echo __FUNCTION__,"\n"; }
11    const FOO = 1;
12    const BAR = 2;
13}
14namespace Fiz\Biz\Buz {
15
16    use function Foo\Bar\{
17        fiz,
18        biz,
19        buz as boz,
20        A // <- this one must fail
21    };
22
23    use const Foo\Bar\{
24        FOO as FOZ,
25        BAR,
26        B // <- this one must fail
27    };
28
29    use Foo\Bar\{ A, B, const BAR as BOZ };
30
31    function buz(){ echo __FUNCTION__,"\n"; }
32    const FOO = 100;
33
34    echo "==== MIXED ====\n";
35    new A();
36    new B();
37    var_dump(BOZ);
38    echo "===== CONSTANTS ====\n";
39    var_dump(FOO);
40    var_dump(FOZ);
41    var_dump(BAR);
42    var_dump(defined('B'));
43    echo "===== FUNCTIONS ====\n";
44    buz();
45    fiz();
46    biz();
47    boz();
48    A();
49}
50--EXPECTF--
51==== MIXED ====
52Foo\Bar\A::__construct
53Foo\Bar\B::__construct
54int(2)
55===== CONSTANTS ====
56int(100)
57int(1)
58int(2)
59bool(false)
60===== FUNCTIONS ====
61Fiz\Biz\Buz\buz
62Foo\Bar\fiz
63Foo\Bar\biz
64Foo\Bar\buz
65
66Fatal error: Uncaught Error: Call to undefined function Foo\Bar\A() in %sns_092.php:45
67Stack trace:
68#0 {main}
69  thrown in %sns_092.php on line 45
70