Menu

← Back to requireExtends.*

Error Identifier: requireExtends.deprecatedTrait

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

/** @deprecated Use NewHelper instead */
trait OldHelper
{
	public function help(): void {}
}

/**
 * @phpstan-require-extends OldHelper
 */
trait MyTrait // ERROR: PHPDoc tag @phpstan-require-extends references deprecated trait OldHelper.
{
}

Why is it reported? #

The @phpstan-require-extends PHPDoc tag references a trait that has been marked as @deprecated. Using deprecated symbols in new code is discouraged because they may be removed in a future version, which would break the requirement.

This rule is provided by the phpstan/phpstan-deprecation-rules extension package.

How to fix it #

Replace the deprecated trait with its suggested replacement:

 <?php declare(strict_types = 1);
 
 /**
- * @phpstan-require-extends OldHelper
+ * @phpstan-require-extends NewHelper
  */
 trait MyTrait
 {
 }

If there is no replacement and the deprecated trait must still be used, the error can be ignored. If the code using the @phpstan-require-extends tag is itself deprecated, the error will not be reported.

How to ignore this error #

You can use the identifier requireExtends.deprecatedTrait to ignore this error using a comment:

// @phpstan-ignore requireExtends.deprecatedTrait
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: requireExtends.deprecatedTrait

Rules that report this error #

  • PHPStan\Rules\Deprecations\RestrictedDeprecatedClassNameUsageExtension [1] phpstan/phpstan-deprecation-rules

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.