Inside a namespace, PHP looks up an unqualified function or constant name in two places: first in your namespace, then in the global one if nothing is found. Class names don't get this fallback. This RFC from Paul M. Jones adds declare(strict_namespace=1), which turns the fallback off for a single file.
How it works
With the directive on, a plain name like strlen() only resolves in your current namespace and won't fall back to the global strlen(). Functions and constants then follow the same rule that classes already do.
declare(strict_namespace=1); namespace Foo; use function str_repeat as repeat; function strlen(string $s): int { return -1; } // Foo\strlen var_dump(strlen('hello')); // int(-1) (unqualified: Foo\strlen) var_dump(\strlen('hello')); // int(5) (fully qualified: global) var_dump(repeat('ab', 3)); // string(6) "ababab" (imported: global)
You can still reach global names in two ways. You can write the fully qualified name with a leading backslash, like \strlen() or \PHP_INT_MAX, or you can import it with use function or use const. The true, false and null keywords work as they always have.
Constants follow the same rule. In strict mode, a plain PHP_INT_MAX inside namespace Foo means Foo\PHP_INT_MAX, so you'd write \PHP_INT_MAX to get the built-in one.
The directive behaves like strict_types:
- It must be the first statement in the file.
- It can't wrap a block of code.
- Its value must be
0or1, where0is the default and keeps today's behavior.
PHP handles it at compile time, and only for that file, so other files aren't affected. The RFC says it has no runtime cost.
The idea grew out of the Function Autoloading RFC. It would help that proposal, but it also stands on its own.
What it means for existing code
Nothing breaks. The directive is opt-in and off by default, so only files that turn it on behave differently.
Where it stands
The page is marked as a draft, first written on July 14, 2026, and it targets PHP 8.6. It has an open discussion thread on the internals list and a pull request with tests. The vote on the page is a placeholder with no votes cast.