Keywords In Namespaces

../_images/keywords_in_namespaces.png

Since PHP 8.0, it is possible to use PHP keywords in namespaces.

In PHP 8.0, namespaces are processed independently, for their literal value. Before then, each namespace level was a distinct token, separated by the namespace separator: PHP keyword would then run into a processing conflict.

The last keyword that one can’t still use in a namespace is namespace, when used as the first part of the namespace : it is later replaced dynamically by the current namespace.

See Also

PHP Features