php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78441 Parse error due to heredoc identifier followed by digit
Submitted: 2019-08-21 17:06 UTC Modified: 2019-08-21 20:57 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.3Git-2019-08-21 (Git) OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2019-08-21 17:06 UTC] cmb@php.net
Description:
------------
If a heredoc/nowdoc identifier is immediately followed by a digit,
it is mistankenly recognized as closing identifier.  While the
documentation on the relaxed heredoc/nowdoc is sparse yet, the
RFC[1] claims:

| The implementation I am proposing avoids this problem by
| checking to see if a continuation of the found marker exists, and
| if so, then if it forms a valid identifier. This means that the
| terminating marker string will only be considered as such if it is
| matched exactly as a standalone, valid symbol (that is also found
| at the start of the line).

Since digits are allowed in identifiers, I think the current behavior
is a bug.

[1] <https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes>

Test script:
---------------
<?php
echo <<<FOO
FOO4
FOO;


Expected result:
----------------
FOO4

Actual result:
--------------
Parse error: syntax error, unexpected '4' (T_LNUMBER), expecting ';' or ',' in %d on line 3

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-21 17:24 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #78441: Parse error due to heredoc identifier followed by digit
On GitHub:  https://github.com/php/php-src/pull/4591
Patch:      https://github.com/php/php-src/pull/4591.patch
 [2019-08-21 20:56 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=310708845ff02b9e252b7a02616290384dd846ba
Log: Fix #78441: Parse error due to heredoc identifier followed by digit
 [2019-08-21 20:56 UTC] cmb@php.net
-Status: Open +Status: Closed
 [2019-08-21 20:57 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC