website/errors/requireExtends.interface.md
<?php declare(strict_types = 1);
interface SomeInterface {}
/**
* @phpstan-require-extends SomeInterface
*/
interface MyInterface {}
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.
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 {}