php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71767 ReflectionMethod::getDocComment returns the wrong comment
Submitted: 2016-03-10 12:52 UTC Modified: -
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: bashofmann at gmail dot com Assigned:
Status: Closed Package: Reflection related
PHP Version: 7.0.4 OS: Ubuntu 14.04
Private report: No CVE-ID: None
 [2016-03-10 12:52 UTC] bashofmann at gmail dot com
Description:
------------
ReflectionMethod::getDocComment returns the wrong comment when one of method's arguments also have a comment.

This worked correctly in PHP5.x

Real world use-case for this would be for example having /** @noinspect */ annotations at the argument for static analysis tools.

See also https://3v4l.org/tR6i5

Test script:
---------------
<?php

class Foo {
    /**
     * Correct docblock
     */
    public function bar(
        /** wrong dockblock */
        $arg
    ) {
        
    }
}

$reflection = new ReflectionClass(Foo::class);

echo $reflection->getMethod('bar')->getDocComment();

Expected result:
----------------
/**
     * Correct docblock
     */

Actual result:
--------------
/** wrong dockblock */

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-11 21:30 UTC] nikic@php.net
Automatic comment on behalf of g.sokolik@delivery-club.ru
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ccc5150f15c747fe5e9b5a17fcb135e7989d0181
Log: Fix bug #71767
 [2016-03-11 21:30 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:33 UTC] davey@php.net
Automatic comment on behalf of g.sokolik@delivery-club.ru
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ccc5150f15c747fe5e9b5a17fcb135e7989d0181
Log: Fix bug #71767
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC