php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80041 Multi-line namespace no longer works with PHP 8
Submitted: 2020-08-31 18:16 UTC Modified: 2020-08-31 18:22 UTC
From: w1djmartin at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 8.0.0beta2 OS: Windows 10
Private report: No CVE-ID: None
 [2020-08-31 18:16 UTC] w1djmartin at gmail dot com
Description:
------------
Prior to PHP 8 Beta 1 splitting a namespace across multiple lines would work without error. Starting with PHP 8 Beta 1 a namespace that is split across multiple lines results in a parse error/syntax error.

Test script:
---------------
namespace Foo
    \Bar
    \Baz;

echo __NAMESPACE__;

Expected result:
----------------
The test script should output: Foo\Bar\Baz

Actual result:
--------------
The test script throws an error: Parse error: syntax error, unexpected fully qualified name "\Bar", expecting "{" 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-31 18:20 UTC] w1djmartin at gmail dot com
You can easily see how the result changes at https://3v4l.org/IWbe1
 [2020-08-31 18:22 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2020-08-31 18:22 UTC] requinix@php.net
That is correct: namespace names are now one whole unit, not multiple names with slashes in between.
https://wiki.php.net/rfc/namespaced_names_as_token
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Dec 05 05:03:37 2021 UTC