phpunit: PHPUnit\Util\Annotation\DocBlock instantiation problem

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.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments