php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #72468 heredoc seem actually supported in static declarations
Submitted: 2016-06-22 09:14 UTC Modified: 2016-06-22 11:04 UTC
From: info at developiu dot it Assigned: cmb (profile)
Status: Closed Package: Documentation problem
PHP Version: 7.0.7 OS: centos linux
Private report: No CVE-ID: None
 [2016-06-22 09:14 UTC] info at developiu dot it
Description:
------------
This bug is similar to bug #70227, but it is related to a different page.

the page at url http://php.net/manual/en/language.oop5.properties.php states the following (see Example #1 property declarations):
"Unlike heredocs, nowdocs can be used in any static data context, including property declarations."

This seem to imply that that heredocs are not allowed in static context but allowed in non static context, but the write proably meant that they always disallowed, as explicitated by the previous example, where the definition of $var2 is marked as invalid even if it is not static.

Actually heredocs can be used to define properties, as the script below shows (with the same syntax marked as invalid in the example given in the documentation abow the "incriminated" phrase). If you run it you'll see no error.

BTW: is there a way for me to propose a patch to some file in order to minimize your work on fixing these sort of bugs?

Test script:
---------------
<?php

error_reporting(E_ALL);

class SimpleClass
{
   public  $var2 = <<<EOD
hello world
EOD;
}
$a=new SimpleClass();
echo $a->var2;

?>



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-22 09:17 UTC] info at developiu dot it
I noticed only now that also the previous declaration is accepted by my version of php, namely the following one:
public $var1 = 'hello ' . 'world';
 [2016-06-22 10:36 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2016-06-22 10:36 UTC] cmb@php.net
Indeed, Nowdoc as well as Heredoc syntax is supported as of PHP
5.3.0, see <https://3v4l.org/bWajs>. Thanks!

> BTW: is there a way for me to propose a patch to some file in
> order to minimize your work on fixing these sort of bugs?

Normally, you could submit patches via the online editor
(<https://edit.php.net/>). Unfortunately, the certificate has been
expired and not yet been renewed, so the editor is not usable
currently[1].

For now you might submit patches to this bug tracker; see also
<http://doc.php.net/tutorial/>.

[1] <https://bugs.php.net/72349>
 [2016-06-22 10:39 UTC] cmb@php.net
Further reference: <https://3v4l.org/j6uW9>.
 [2016-06-22 11:03 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339448
Log: Fix #72468: heredoc seem actually supported in static declarations
 [2016-06-22 11:04 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2016-06-22 11:04 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:07 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=fa568719e176d2a678f7d7511b2410ee3b792b90
Log: Fix #72468: heredoc seem actually supported in static declarations
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 05:00:01 2026 UTC