phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

`@requires PHP >= 8.2` produces an empty `__OFFSET_FILE` content

Open llaville opened this issue 3 years ago • 0 comments

Hello

Q A
PHPUnit version 9.5.x
PHP version 7.4.30 or 8.0.23 or 8.1.10
Installation Method PHAR or tool via https://github.com/shivammathur/setup-php GitHub Action

Summary

Annotation @requires PHP >= 8.2 produces an empty __OFFSET_FILE content at runtime.

Current behavior

Detect location from https://github.com/sebastianbergmann/phpunit/blob/9.5/src/Framework/Assert.php#L2811-L2833 produces an empty __OFFSET_FILE content while __OFFSET_LINE is filled.

Something like :

1) Bartlett\CompatInfoDb\Tests\Reference\Extension\PhpBundle\Core\Php82FeatureTest::testWithoutAllowDynamicPropertiesAttribute
__OFFSET_LINE=22
__OFFSET_FILE=
PHP >= 8.2 is required.

2) Bartlett\CompatInfoDb\Tests\Reference\Extension\PhpBundle\Core\Php82FeatureTest::testAllowDynamicPropertiesAttribute
__OFFSET_LINE=22
__OFFSET_FILE=
PHP >= 8.2 is required.

3) Bartlett\CompatInfoDb\Tests\Reference\Extension\PhpBundle\Core\Php82FeatureTest::testSensitiveParameter
__OFFSET_LINE=22
__OFFSET_FILE=
PHP >= 8.2 is required.

4) Bartlett\CompatInfoDb\Tests\Reference\Extension\PhpBundle\Core\Php82FeatureTest::testReadOnlyClasses
__OFFSET_LINE=22
__OFFSET_FILE=
PHP >= 8.2 is required.

How to reproduce

Add a TestCase class with @requires PHP >= 8.2 annotation into phpdoc

Expected behavior

__OFFSET_LINE filled with the php filename that include the TestCase

Runtime example with GitHub Action available at https://github.com/llaville/php-compatinfo-db/actions/runs/3103348027/jobs/5026593614

Source code (TestCase) available at https://github.com/llaville/php-compatinfo-db/blob/master/tests/Reference/Extension/PhpBundle/Core/Php82FeatureTest.php

llaville avatar Sep 22 '22 07:09 llaville