Bug #79062 [Opn->Ver]: Property with heredoc default value returns false for getDocComment
| From: | cmb@php.net | Date: | Sun, 05 Jan 2020 11:42:40 +0000 |
| Subject: | Bug #79062 [Opn->Ver]: Property with heredoc default value returns false for getDocComment | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224708@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79062&edit=1
ID: 79062
Updated by: cmb@php.net
Reported by: ondrej at mirtes dot cz
Summary: Property with heredoc default value returns false
for getDocComment
-Status: Open
+Status: Verified
Type: Bug
Package: Reflection related
Operating System: any
PHP Version: 7.4.1
Block user comment: N
Private report: N
New Comment:
Introduced by <http://git.php.net/?p=php-src.git;a=commit;h=4887357269107ed669463c4b95bd755fbbb52490>.
Previous Comments:
------------------------------------------------------------------------
[2020-01-04 13:11:32] ondrej at mirtes dot cz
Description:
------------
If property is assigned a default string value in the form of heredoc, its
ReflectionProperty::getDocComment() returns false even if there's a PHPDoc.
Looks like this bug was introduced in PHP 7.3.0: https://3v4l.org/4fRLA
Related PHPStan bug: https://github.com/phpstan/phpstan/issues/2742
Test script:
---------------
<?php
class BugReportMailrcConfigTests
{
/** @var string */
private $s1 = <<<STRING
I'm a string :(
STRING;
/** @var string */
private $s2 = <<<'STRING'
I'm a string :)
STRING;
/** @var string */
private $s3 = 'I\'m a string :)';
}
$ref = new \ReflectionClass(BugReportMailrcConfigTests::class);
$s1 = $ref->getProperty('s1');
var_dump($s1->getDocComment());
$s2 = $ref->getProperty('s2');
var_dump($s2->getDocComment());
$s3 = $ref->getProperty('s3');
var_dump($s2->getDocComment());
Expected result:
----------------
string(18) "/** @var string */"
string(18) "/** @var string */"
string(18) "/** @var string */"
Actual result:
--------------
bool(false)
string(18) "/** @var string */"
string(18) "/** @var string */"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79062&edit=1