Menu

← Back to requireExtends.*

Error Identifier: requireExtends.onInterface

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

/**
 * @phpstan-require-extends Base
 */
class MyClass
{

}

Why is it reported? #

The @phpstan-require-extends PHPDoc tag is only valid on traits and interfaces. It is used to constrain which classes can use a trait or implement an interface by requiring them to extend a specific base class. Using it on a regular class or enum has no meaning because classes and enums do not impose extension requirements on their users.

How to fix it #

If you intended to use this on a trait, change the declaration:

 <?php declare(strict_types = 1);
 
 /**
  * @phpstan-require-extends Base
  */
-class MyClass
+trait MyTrait
 {

 }

If you intended to use this on an interface, change the declaration:

 <?php declare(strict_types = 1);
 
 /**
  * @phpstan-require-extends Base
  */
-class MyClass
+interface MyInterface
 {

 }

If neither is appropriate, remove the tag:

 <?php declare(strict_types = 1);
 
-/**
- * @phpstan-require-extends Base
- */
 class MyClass
 {

 }

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\PhpDoc\RequireExtendsDefinitionClassRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.