Error Identifier: interface.extendsInternalInterface
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);
namespace App;
// In package vendor/some-package:
// /** @internal */
// interface InternalServiceInterface {}
interface MyServiceInterface extends \Vendor\InternalServiceInterface
{
}
Why is it reported? #
The interface extends another interface that is marked as @internal. Internal interfaces are not part of the package’s public API and may change or be removed without notice in future versions. Extending an internal interface couples your code to implementation details that may break when the dependency is updated.
How to fix it #
Extend a non-internal interface instead, or define the required methods directly:
<?php declare(strict_types = 1);
namespace App;
-interface MyServiceInterface extends \Vendor\InternalServiceInterface
+interface MyServiceInterface
{
+ public function execute(): void;
}
If the package provides a public interface for the same purpose, extend that instead:
<?php declare(strict_types = 1);
namespace App;
-interface MyServiceInterface extends \Vendor\InternalServiceInterface
+interface MyServiceInterface extends \Vendor\PublicServiceInterface
{
}
If no public alternative exists, consider reaching out to the package maintainers to request a public API for your use case.
How to ignore this error #
You can use the identifier interface.extendsInternalInterface to ignore this error using a comment:
// @phpstan-ignore interface.extendsInternalInterface
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: interface.extendsInternalInterface
Rules that report this error #
- PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]