diff --git a/src/Metadata/Parser/Annotation/DocBlock.php b/src/Metadata/Parser/Annotation/DocBlock.php index 0d6036960f2..486cf638d8b 100644 --- a/src/Metadata/Parser/Annotation/DocBlock.php +++ b/src/Metadata/Parser/Annotation/DocBlock.php @@ -130,8 +130,8 @@ public function requirements(): array '__FILE' => realpath($this->fileName), ]; - // Split docblock into lines and rewind offset to start of docblock - $lines = preg_split('/\r\n|\r|\n/', $this->docComment); + // Trim docblock markers, split it into lines and rewind offset to start of docblock + $lines = preg_replace(['#^/\*{2}#', '#\*/$#'], '', preg_split('/\r\n|\r|\n/', $this->docComment)); $offset -= count($lines); foreach ($lines as $line) { diff --git a/tests/_files/Metadata/Annotation/tests/RequiresPhpTest.php b/tests/_files/Metadata/Annotation/tests/RequiresPhpTest.php index 39190bce6f2..da54ec38248 100644 --- a/tests/_files/Metadata/Annotation/tests/RequiresPhpTest.php +++ b/tests/_files/Metadata/Annotation/tests/RequiresPhpTest.php @@ -22,4 +22,9 @@ final class RequiresPhpTest extends TestCase public function testOne(): void { } + + /** @requires PHP < 9.0.0 */ + public function testTwo(): void + { + } } diff --git a/tests/unit/Metadata/Parser/AnnotationParserTest.php b/tests/unit/Metadata/Parser/AnnotationParserTest.php index 1df83cea1bf..c8e8e0f2126 100644 --- a/tests/unit/Metadata/Parser/AnnotationParserTest.php +++ b/tests/unit/Metadata/Parser/AnnotationParserTest.php @@ -587,9 +587,17 @@ public function test_Parses_requiresOperatingSystemFamily_annotation_on_method() $this->assertSame('Linux', $metadata->asArray()[0]->operatingSystemFamily()); } - public function test_Parses_requiresPhp_annotation_on_method(): void + public function provideRequiresPhpTestMethods(): array { - $metadata = (new AnnotationParser)->forMethod(RequiresPhpTest::class, 'testOne')->isRequiresPhp(); + return [['testOne'], ['testTwo']]; + } + + /** + * @dataProvider provideRequiresPhpTestMethods + */ + public function test_Parses_requiresPhp_annotation_on_method(string $method): void + { + $metadata = (new AnnotationParser)->forMethod(RequiresPhpTest::class, $method)->isRequiresPhp(); $this->assertCount(1, $metadata);