Bug->Req #81583 [Opn]: Accessing class constants on objects in string interpolation
| From: | nikic@php.net | Date: | Mon, 01 Nov 2021 13:17:28 +0000 |
| Subject: | Bug->Req #81583 [Opn]: Accessing class constants on objects in string interpolation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237485@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81583&edit=1
ID: 81583
Updated by: nikic@php.net
Reported by: php at crmteam dot cytainment dot de
-Summary: ::class on objects using string concatenation
+Summary: Accessing class constants on objects in string
interpolation
Status: Open
-Type: Bug
+Type: Feature/Change Request
Package: *General Issues
Operating System: Debian 10
PHP Version: 8.0.12
Block user comment: N
Private report: N
New Comment:
This is not really specific to ::class, applies to $a::XYZ generally. In any case, this is clearly a
feature request.
Previous Comments:
------------------------------------------------------------------------
[2021-11-01 10:03:59] 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"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81583&edit=1