Bug->Doc #65011 [Opn->Ver]: ReflectionProperty::getDocComment() fails for multiple variable declarations
| From: | cmb@php.net | Date: | Sat, 30 Jun 2018 12:39:28 +0000 |
| Subject: | Bug->Doc #65011 [Opn->Ver]: ReflectionProperty::getDocComment() fails for multiple variable declarations | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15835@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65011&edit=1
ID: 65011
Updated by: cmb@php.net
Reported by: benjamin dot morel at gmail dot com
Summary: ReflectionProperty::getDocComment() fails for
multiple variable declarations
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
Package: Reflection related
Operating System: CentOS 6.4
PHP Version: 5.4.16
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> I'd keep the current way.
Okay, switching to doc problem.
Previous Comments:
------------------------------------------------------------------------
[2013-06-29 19:25:28] 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.
------------------------------------------------------------------------
[2013-06-24 00:14:29] felipe@php.net
Johannes, what is your opinion about this suggestion?
------------------------------------------------------------------------
[2013-06-11 10:54:07] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65011&edit=1