No New Line In Namespaces¶
Until PHP 8.0, it was possible to use new lines inside a namespace: they would be removed at execution time, to build the actual namespace. Since PHP 8.0, it is not allowed anymore.
PHP code¶
<?php
// constant
\A
\B
\C
;
// type
function foo() : \A
\B
\C
{}
?>
Before¶
PHP Parse error: syntax error, unexpected ';', expecting '{'
Parse error: syntax error, unexpected ';', expecting '{'
After¶
PHP Parse error: syntax error, unexpected fully qualified name \B
Parse error: syntax error, unexpected fully qualified name \B
PHP version change¶
This behavior changed in 8.0