Req #65056 [Opn->Csd]: Is there a plan for adding a ReflectionParameter::getDocComment() method?
| From: | cmb@php.net | Date: | Tue, 08 Dec 2020 12:59:19 +0000 |
| Subject: | Req #65056 [Opn->Csd]: Is there a plan for adding a ReflectionParameter::getDocComment() method? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230937@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65056&edit=1
ID: 65056
Updated by: cmb@php.net
Reported by: benjamin dot morel at gmail dot com
Summary: Is there a plan for adding a
ReflectionParameter::getDocComment() method?
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Reflection related
Operating System: N/A
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Indeed, this should be superseded by attributes.
Previous Comments:
------------------------------------------------------------------------
[2020-09-28 20:02:17] benjamin dot morel at gmail dot com
Please note that the use case above is irrelevant now that attributes have been introduced. There is
probably no other use case for doc comments on parameters, so I think this feature request can be
closed.
------------------------------------------------------------------------
[2016-01-07 11:37:24] tpunt@php.net
This is not a documentation problem - The ReflectionParameter::getDocComment() function simply does
not exist.
The engine currently does not support doc comments on a per-parameter basis, hence why it has not
been exposed in the ReflectionParameter class.
------------------------------------------------------------------------
[2013-06-18 11:52:14] benjamin dot morel at gmail dot com
Description:
------------
I've never seen any discussion regarding the addition of a
ReflectionParameter::getDocComment() method.
The only mention I've found is in this post from 2005(!):
http://news.php.net/php.internals/14906
This would be a very useful feature for dependency injection frameworks.
For example, if you want to use annotations to configure dependency injection on
the following class:
class Service
{
public function __construct(PDO $pdo, $configuration)
{
}
}
You would need to do something like:
class Service
{
/**
* @InjectParam(name="pdo", value="database.connection")
* @InjectParam(name="configuration", value="database.configuration")
*/
public function __construct(PDO $pdo, $configuration)
{
}
}
Whereas we could benefit from the following approach:
class Service
{
public function __construct(
/** @Inject("database.connection") */ PDO $pdo,
/** @Inject("database.configuration") */ $configuration)
{
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65056&edit=1