php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65011 ReflectionProperty::getDocComment() fails for multiple variable declarations
Submitted: 2013-06-11 10:54 UTC Modified: 2018-06-30 12:42 UTC
From: benjamin dot morel at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Reflection related
PHP Version: 5.4.16 OS: CentOS 6.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: benjamin dot morel at gmail dot com
New email:
PHP Version: OS:

 

 [2013-06-11 10:54 UTC] benjamin dot morel at gmail dot com
Description:
------------
When multiple class properties are declared at once, 
ReflectionProperty::getDocComment() only returns the doc comment for the first 
one.

I believe that the doc comment applies to all of the properties if they're 
declared together, so getDocComment() should return the same value for all of 
them, not just the first one.

Test script:
---------------
class Foo {
    /** @var string */
    public $a, $b;
}

$class = new \ReflectionClass('Foo');
foreach ($class->getProperties() as $property) {
    echo $property->getName() . ': ' . var_export($property->getDocComment(), true) . PHP_EOL;
}

Expected result:
----------------
a: '/** @var string */'
b: '/** @var string */'

Actual result:
--------------
a: '/** @var string */'
b: false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-24 00:14 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: johannes
 [2013-06-24 00:14 UTC] felipe@php.net
Johannes, what is your opinion about this suggestion?
 [2013-06-29 19:25 UTC] johannes@php.net
-Status: Assigned +Status: Open -Assigned To: johannes +Assigned To:
 [2013-06-29 19:25 UTC] johannes@php.net
i don't think it is the right thing to do. Let's extend through example:

class C {
   /**
    * foo
    */
   public $foo,
   /**
    * bar
    */
    $bar;
}

if we here take the doc comment from foo for both it becomes weird (ok, the code is weird, 
tion) taking bar we make the grammar more complex. I'd keep the current way.
 [2018-06-30 12:39 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: cmb
 [2018-06-30 12:39 UTC] cmb@php.net
> I'd keep the current way.

Okay, switching to doc problem.
 [2018-06-30 12:42 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=345251
Log: Fix #65011: ReflectionProperty::getDocComment() fails for multiple variable declarations

We add an example to clarify the behavior.
 [2018-06-30 12:42 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2018-06-30 12:42 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:05 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=1c1b29f597bd56dcd072736f5ca601a4b6f54a72
Log: Fix #65011: ReflectionProperty::getDocComment() fails for multiple variable declarations
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 19:01:29 2024 UTC