Skip to content

Commit 359966e

Browse files
committed
Add test for calling pinned FQN name to global
1 parent 47a528a commit 359966e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Fallback to global function should trigger autoloading only once per namespace.
3+
--FILE--
4+
<?php
5+
6+
namespace Bar {
7+
if ( function_exists('Foo\strlen') ) {
8+
var_dump(\Foo\strlen('hello'));
9+
}
10+
}
11+
namespace Foo {
12+
var_dump(strlen('hello')); // triggers name pinning
13+
}
14+
namespace Bar {
15+
if ( function_exists('Foo\strlen') ) {
16+
echo '\Foo\strlen() was bound to global \strlen()', \PHP_EOL;
17+
var_dump(\Foo\strlen('hello'));
18+
}
19+
}
20+
21+
?>
22+
--EXPECT--
23+
int(5)
24+
\Foo\strlen() was bound to global \strlen()
25+
int(5)

0 commit comments

Comments
 (0)