Menu

← Back to requireExtends.*

Error Identifier: requireExtends.interface

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

interface SomeInterface {}

/**
 * @phpstan-require-extends SomeInterface
 */
interface MyInterface {}

Why is it reported? #

The @phpstan-require-extends PHPDoc tag is used to require that a class using a trait or implementing an interface must extend a specific class. However, it only accepts class names, not interfaces. The tag refers to extends in the class inheritance sense, which in PHP applies only to classes.

If you want to require that a class implements a specific interface, the @phpstan-require-implements tag should be used instead.

How to fix it #

If you meant to require that the implementing class also implements a specific interface, use @phpstan-require-implements:

 <?php declare(strict_types = 1);
 
 interface SomeInterface {}

 /**
- * @phpstan-require-extends SomeInterface
+ * @phpstan-require-implements SomeInterface
  */
 interface MyInterface {}

If you meant to require extending a specific class, provide a class name instead of an interface:

 <?php declare(strict_types = 1);
 
 class SomeBaseClass {}

 /**
- * @phpstan-require-extends SomeInterface
+ * @phpstan-require-extends SomeBaseClass
  */
 interface MyInterface {}

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\PhpDoc\RequireExtendsDefinitionClassRule [1] [2]
  • PHPStan\Rules\PhpDoc\RequireExtendsDefinitionTraitRule [1] [2]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.