Skip to content

Improve documentation of version constraints for attributes such as #[RequiresPhp] #391

@kubawerlos

Description

@kubawerlos
<?php

class FooTest extends \PHPUnit\Framework\TestCase
{
    /**
     * @requires PHP 8.1
     **/
    public function test1() { self::assertTrue(true); }

    #[\PHPUnit\Framework\Attributes\RequiresPhp('8.1')]
    public function test2() { self::assertTrue(true); }
}
$ phpunit test.php --display-skipped
PHPUnit 11.5.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.3

S.                                                                                                                                  2 / 2 (100%)

Time: 00:00.016, Memory: 18.00 MB

There was 1 skipped test:

1) FooTest::test2
PHP 8.1 is required.

The ^ is needed in the attribute to make it work the same as PHPDoc. Is this expected behaviour or a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementExisting documentation can be improved

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions