Bug #79062 [Ver->Csd]: Property with heredoc default value returns false for getDocComment

From: Date: Fri, 28 Feb 2020 16:08:47 +0000
Subject: Bug #79062 [Ver->Csd]: Property with heredoc default value returns false for getDocComment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225795@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: nikic@php.net Reported by: ondrej at mirtes dot cz Summary: Property with heredoc default value returns false for getDocComment -Status: Verified +Status: Closed Type: Bug Package: Reflection related Operating System: any PHP Version: 7.4.1 Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=6c48da9a50a68cbb27873ead6bf936494c006236 Log: Fixed bug #79062 Previous Comments: ------------------------------------------------------------------------ [2020-01-05 11:42:40] cmb@php.net Introduced by <http://git.php.net/?p=php-src.git;a=commit;h=4887357269107ed669463c4b95bd755fbbb52490>. ------------------------------------------------------------------------ [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

« previous php.bugs (#225795) next »