website/errors/requireExtends.onTrait.md
<?php declare(strict_types = 1);
/**
* @phpstan-require-extends SomeClass
*/
class InvalidClass
{
}
The @phpstan-require-extends PHPDoc tag is placed on a class. This tag is only valid on traits and interfaces. On a trait, it ensures that any class using the trait extends a specific base class. On an interface, it ensures that implementing classes extend a specific base class. Using it on a regular class has no effect and indicates a mistake.
Remove the @phpstan-require-extends tag from the class:
-/**
- * @phpstan-require-extends SomeClass
- */
class InvalidClass
{
}
If the constraint is intended, move it to a trait or interface where @phpstan-require-extends is valid:
/**
* @phpstan-require-extends SomeClass
*/
-class InvalidClass
+trait MyTrait
{
}