|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79942 b/c break: new\class now fails
Submitted: 2020-08-07 11:15 UTC Modified: 2020-08-10 09:26 UTC
From: Assigned: sjon (profile)
Status: Closed Package: Class/Object related
PHP Version: 8.0.0beta1 OS: archLinux
Private report: No CVE-ID: None
 [2020-08-07 11:15 UTC]
It's no longer to create an object from a specific namespace without a trailing space after the 'new' keyword. This change is not documented as b/c incompatible change in the NEWS or UPGRADING file. Somewhat inconsistently, `new$x` still works:

originally found as

Test script:

class x {}

Actual result:
Fatal error: Uncaught Error: Undefined constant "new\x" in /in/KsknY:4


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-07 11:51 UTC]
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2020-08-07 11:51 UTC]
That behavioral change is due to "RFC: Treat namespaced names as
single token"[1]; new\x is now a single token (same for some other
operators, e.g. instanceof).  That needs to be documented.

> Somewhat inconsistently, `new$x` still works […]

TIL, but actually not really surprising, since the scanner
"automatically" sees two tokens here.

[1] <>
 [2020-08-10 09:20 UTC]
I have added a mention of this case to the UPGRADING note:
 [2020-08-10 09:26 UTC]
-Status: Verified +Status: Closed -Assigned To: +Assigned To: sjon
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 11:01:32 2024 UTC