Bug #74044 [Opn->Nab]: Parse error when using $this::CONSTANT in Heredoc

From: Date: Thu, 22 Aug 2019 06:51:55 +0000
Subject: Bug #74044 [Opn->Nab]: Parse error when using $this::CONSTANT in Heredoc
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222361@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74044&edit=1 ID: 74044 Updated by: cmb@php.net Reported by: olivier dot laviale at gmail dot com -Summary: Parse error when using $this::CONSTRANT in Heredoc +Summary: Parse error when using $this::CONSTANT in Heredoc -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: MacOS PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php From the docs[1]: | When a string is specified in double quotes or with heredoc, | variables are parsed within it. A constant isn't a variable. [1] <https://www.php.net/manual/en/language.types.string.php#language.types.string.parsing> Previous Comments: ------------------------------------------------------------------------ [2017-02-05 09:38:43] olivier dot laviale at gmail dot com Description: ------------ Using {$this::CONSTANT} in Heredoc causes a parse error. Test script: --------------- <?php class A { const A = 'a'; static private $c; public function render() { return <<<EOT '{$this::$c}' '{$this::A}' EOT; } } Expected result: ---------------- {$this::A} should yield the constant value in Heredoc. Actual result: -------------- 7.0.0 - 7.1.1: Parse error: syntax error, unexpected '}', expecting '[' 5.6.0 - 5.6.30: Parse error: syntax error, unexpected '}', expecting '(' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74044&edit=1

« previous php.bugs (#222361) next »