xref: /PHP-7.3/Zend/tests/ns_026.phpt (revision b746e698)
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--EXPECTF--
29Method - Foo\Foo::__construct
30Func   - Foo\Bar
31Method - Foo\Foo::__construct
32Method - Foo\Foo::Bar
33Func   - Foo\Bar
34
35Fatal error: Uncaught Error: Call to undefined function Foo\Foo\Bar() in %sns_026.php:%d
36Stack trace:
37#0 {main}
38  thrown in %sns_026.php on line %d
39