php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65056 Is there a plan for adding a ReflectionParameter::getDocComment() method?
Submitted: 2013-06-18 11:52 UTC Modified: 2020-12-08 12:59 UTC
From: benjamin dot morel at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Reflection related
PHP Version: Irrelevant OS: N/A
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-18 11:52 UTC] 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)
    {
    }
}



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-26 06:59 UTC] frozenfire@php.net
-Type: Feature/Change Request +Type: Documentation Problem
 [2016-01-07 11:37 UTC] tpunt@php.net
-Type: Documentation Problem +Type: Feature/Change Request
 [2016-01-07 11:37 UTC] 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.
 [2020-09-28 20:02 UTC] 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.
 [2020-12-08 12:59 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-12-08 12:59 UTC] cmb@php.net
Indeed, this should be superseded by attributes.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC