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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: w1djmartin at gmail dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC