Error Identifier: phpstanApi.attribute

← Back to phpstanApi.*

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);

namespace App;

use PHPStan\DependencyInjection\ContainerExtension;

#[ContainerExtension(name: 'foo')]
class Extension extends \Nette\DI\CompilerExtension
{

}

Why is it reported? #

The code uses an attribute class from PHPStan that is meant only for PHPStan’s own internal use. Such attributes are not processed when used in third-party code like extensions, so they simply will not work as expected — for example the class will not be registered or configured the way the attribute suggests.

Only attribute classes marked with the @api PHPDoc tag (like #[RegisteredRule], #[AutowiredService] or #[AutowiredParameter]) are supported outside of PHPStan itself.

How to ignore this error #

You can use the identifier phpstanApi.attribute to ignore this error using a comment:

// @phpstan-ignore phpstanApi.attribute
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: phpstanApi.attribute

Rules that report this error #

  • PHPStan\Rules\Classes\ClassAttributesRule [1]
  • PHPStan\Rules\Classes\ClassConstantAttributesRule [1]
  • PHPStan\Rules\Constants\ConstantAttributesRule [1]
  • PHPStan\Rules\EnumCases\EnumCaseAttributesRule [1]
  • PHPStan\Rules\Functions\ArrowFunctionAttributesRule [1]
  • PHPStan\Rules\Functions\ClosureAttributesRule [1]
  • PHPStan\Rules\Functions\FunctionAttributesRule [1]
  • PHPStan\Rules\Functions\ParamAttributesRule [1]
  • PHPStan\Rules\Methods\MethodAttributesRule [1]
  • PHPStan\Rules\Properties\PropertyAttributesRule [1]
  • PHPStan\Rules\Properties\PropertyHookAttributesRule [1]
  • PHPStan\Rules\Traits\TraitAttributesRule [1]
Theme
© 2026 PHPStan s.r.o.