xref: /PHP-8.0/Zend/tests/ns_026.phpt (revision 7aacc705)
1--TEST--
2026: Name ambiguity (class name & namespace name)
3--INI--
4opcache.optimization_level=0
5--FILE--
6<?php
7namespace Foo;
8
9class Foo {
10  function __construct() {
11    echo "Method - ".__CLASS__."::".__FUNCTION__."\n";
12  }
13  static function Bar() {
14    echo "Method - ".__CLASS__."::".__FUNCTION__."\n";
15  }
16}
17
18function Bar() {
19  echo "Func   - ".__FUNCTION__."\n";
20}
21
22$x = new Foo;
23\Foo\Bar();
24$x = new \Foo\Foo;
25\Foo\Foo::Bar();
26\Foo\Bar();
27Foo\Bar();
28?>
29--EXPECTF--
30Method - Foo\Foo::__construct
31Func   - Foo\Bar
32Method - Foo\Foo::__construct
33Method - Foo\Foo::Bar
34Func   - Foo\Bar
35
36Fatal error: Uncaught Error: Call to undefined function Foo\Foo\Bar() in %sns_026.php:%d
37Stack trace:
38#0 {main}
39  thrown in %sns_026.php on line %d
40