php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79062 Property with heredoc default value returns false for getDocComment
Submitted: 2020-01-04 13:11 UTC Modified: 2020-01-05 11:42 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ondrej at mirtes dot cz Assigned:
Status: Closed Package: Reflection related
PHP Version: 7.4.1 OS: any
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: ondrej at mirtes dot cz
New email:
PHP Version: OS:

 

 [2020-01-04 13:11 UTC] 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 */"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-05 11:42 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2020-02-28 16:08 UTC] nikic@php.net
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
 [2020-02-28 16:08 UTC] nikic@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 01 17:01:32 2024 UTC