website/errors/requireExtends.finalClass.md
<?php declare(strict_types = 1);
final class BaseService
{
}
/**
* @phpstan-require-extends BaseService
*/
interface ServiceAware
{
}
The @phpstan-require-extends PHPDoc tag references a class that is declared as final. A final class cannot be extended, so requiring that implementing classes extend it is impossible to satisfy. Any class that would implements ServiceAware could never also extends BaseService because PHP forbids extending final classes.
If the class should be extendable, remove the final modifier:
<?php declare(strict_types = 1);
-final class BaseService
+class BaseService
{
}
/**
* @phpstan-require-extends BaseService
*/
interface ServiceAware
{
}
If the class must remain final, remove the @phpstan-require-extends tag and consider using @phpstan-require-implements with an interface instead:
<?php declare(strict_types = 1);
+interface BaseServiceInterface
+{
+}
+
/**
- * @phpstan-require-extends BaseService
+ * @phpstan-require-implements BaseServiceInterface
*/
interface ServiceAware
{
}