Closed IanDelMar closed 2 months ago
Do we need to bump phpstan version?
I don't think so. RuleErrorBuilder::message(...)->identifier(...)
has been around for a while now. See this link. The new interface IdentifierRuleError extends RuleError
and simply adds a method to retrieve the identifier. Older versions of PHPStan don't know about this interface and do not use the getIdentifier()
method. Newer versions of PHPStan complain about using the RuleError
interface instead of the IdentifierRuleError
interface.
It should be sufficient to ignore these errors.
However, we should be considerate about identifier names. If people use the identifiers to ignore errors, they won't be happy if the identifiers change.
Thank you, Ian.
This PR introduces rule error identifiers for the following rules:
IsWpErrorRule
HookDocsRule
HookCallbackRule
The identifiers are sourced from the PHPStan code base, except for
paramTag.count
. PHPStan does not have a corresponding error identifier for this; there isarguments.count
, but this handles arguments, not tags. If anyone has better ideas on how to name the identifiers, I am happy to change them.For
HookDocsRule
andHookCallbackRule
, this PR replaces the try-catch blocks with checks for existing errors in an array holding the errors and removes the exceptions since they are no longer used. Keeping the exceptions would have required different exceptions for each error identifier to retrieve the correct identifier if the exception is thrown.Changes not related to error identifiers:
HookCallbackRule::getAcceptedArgs()
.HookCallbackRule::validateActionReturnType()
andHookCallbackRule::validateFilterReturnType()
on the return type instead of on the callable acceptor.HookCallbackRule::isNever()
toHookCallbackRule::isExplicitNever()
to be more explicit about the method's functionality.