Skip to content

PHPUnit\Util\Annotation\DocBlock instantiation problem #4128

@X-Coder264

Description

@X-Coder264
Q A
PHPUnit version 8.5.2
PHP version 7.2.28
Installation Method Composer

Current behavior

\PHPUnit\Util\Annotation\DocBlock::ofMethod tries to instantiate the DocBlock class, the problem is that it doesn't check if the \ReflectionMethod $method that it receives contains all the needed data that is passed to the constructor. For example I ran into a case where $method->getStartLine(), $method->getEndLine() etc returns false, but the constructor expects int and everything breaks then.

Argument 4 passed to PHPUnit\Util\Annotation\DocBlock::__construct() must be of the type integer, boolean given, called in /webroot_data/webroot/vendor/phpunit/phpunit/src/Util/Annotation/DocBlock.php on line 118

Screenshot from 2020-03-02 11-32-24

How to reproduce

Call \PHPUnit\Util\Annotation\DocBlock::ofMethod with an \ReflectionMethod instance which only has the class and name properties set.

Expected behavior

The \PHPUnit\Util\Annotation\DocBlock class should be instantiated without errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions