Error Identifier: phpstanApi.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);
use PHPStan\Analyser\Scope;
class MyScope implements Scope
{
// ...
}
Why is it reported? #
The code implements or extends a PHPStan interface that is not covered by the backward compatibility promise. The interface might change in a minor PHPStan version, which could break your implementation.
PHPStan marks certain interfaces with @api to indicate they are safe to implement. Interfaces without this tag, or those marked with @api-do-not-implement, are considered internal and may have methods added or changed in any minor release.
How to fix it #
Use only interfaces that are covered by the backward compatibility promise (marked with @api). Check the PHPStan source code to see if the interface you want to implement is part of the public API.
If you believe the interface should be covered by the backward compatibility promise, open a discussion at https://github.com/phpstan/phpstan/discussions.
Learn more: Backward Compatibility Promise
How to ignore this error #
You can use the identifier phpstanApi.interface to ignore this error using a comment:
// @phpstan-ignore phpstanApi.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: phpstanApi.interface