Menu

← Back to phpunit.*

Error Identifier: phpunit.invalidPhpDoc

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

class MyTest extends \PHPUnit\Framework\TestCase
{
	/**
	 * @dataProvidergetData
	 */
	public function testSomething(int $value): void
	{
	}
}

Why is it reported? #

This error is reported by the phpstan-phpunit extension.

A PHPUnit annotation like @dataProvider, @covers, @depends, @group, or similar is missing a space between the annotation name and its value. PHPUnit requires these annotations to have a space separating the tag from its parameter. Without the space, PHPUnit will not recognise the annotation and will silently ignore it.

How to fix it #

Add a space between the annotation name and its value:

 /**
- * @dataProvidergetData
+ * @dataProvider getData
  */
 public function testSomething(int $value): void
 {
 }

How to ignore this error #

You can use the identifier phpunit.invalidPhpDoc to ignore this error using a comment:

// @phpstan-ignore phpunit.invalidPhpDoc
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: phpunit.invalidPhpDoc

Rules that report this error #

  • PHPStan\Rules\PHPUnit\NoMissingSpaceInClassAnnotationRule [1] phpstan/phpstan-phpunit
  • PHPStan\Rules\PHPUnit\NoMissingSpaceInMethodAnnotationRule [1] phpstan/phpstan-phpunit

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.