php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #81583 Accessing class constants on objects in string interpolation
Submitted: 2021-11-01 10:03 UTC Modified: 2024-07-28 04:22 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: php at crmteam dot cytainment dot de Assigned: cmb (profile)
Status: No Feedback Package: *General Issues
PHP Version: 8.0.12 OS: Debian 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at crmteam dot cytainment dot de
New email:
PHP Version: OS:

 

 [2021-11-01 10:03 UTC] php at crmteam dot cytainment dot de
Description:
------------
The introduced feature ::class on objects is throwing a syntax error when being used in string concatenation using curly braces.

Error:
PHP Parse error:  syntax error, unexpected token "}", expecting "->" or "?->" or "{" or "[" in php shell code on line 1



Test script:
---------------
class Test {};
$a = new Test();
echo "Test " . $a::class;
echo "Test {$a::class}";



Expected result:
----------------
In my opinion the lines 3 and 4 should output the same result "Test Test"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-01 13:17 UTC] nikic@php.net
-Summary: ::class on objects using string concatenation +Summary: Accessing class constants on objects in string interpolation -Type: Bug +Type: Feature/Change Request
 [2021-11-01 13:17 UTC] nikic@php.net
This is not really specific to ::class, applies to $a::XYZ generally. In any case, this is clearly a feature request.
 [2024-07-19 21:47 UTC] cmb@php.net
Are you still interested in this feature?
 [2024-07-19 21:47 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2024-07-28 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC