Bug #79062 [NEW]: Property with heredoc default value returns false for getDocComment
| From: | ondrej at mirtes dot cz | Date: | Sat, 04 Jan 2020 13:11:32 +0000 |
| Subject: | Bug #79062 [NEW]: Property with heredoc default value returns false for getDocComment | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-224701@lists.php.net to get a copy of this message | ||
From: ondrej at mirtes dot cz
Operating system: any
PHP version: 7.4.1
Package: Reflection related
Bug Type: Bug
Bug description:Property with heredoc default value returns false for getDocComment
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 bug report at https://bugs.php.net/bug.php?id=79062&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79062&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79062&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79062&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79062&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79062&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79062&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79062&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79062&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79062&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79062&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79062&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79062&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79062&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79062&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79062&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79062&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79062&r=mysqlcfg