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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 - 5 = ?
Subscribe to this entry?

 
 [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: Thu Mar 28 14:01:29 2024 UTC