Allow flagging a node with an "ignore deprecation" attribute via NodeVisitorAbstract to skip deprecation errors
mglaman opened this issue · 3 comments
A common pattern is to use if/else statements for backward compatibility with deprecated methods to provide support between versions before the deprecation was introduced and to provide a fix for after.
One example can be found here: mglaman/phpstan-drupal#461
if (method_exists($this->moduleHandler, 'invokeAllWIth')) {
// use the new invokeAllWIth method
} else {
// use legacy getImplementations method
}The easiest fix is to add // @phpstan-ignore-next-line whenever using backward compatible code. But I was trying to see if it'd be possible to use a node visitor to detect the if/else to set an attribute flag. Which it does seem possible (whether it is right or wrong.)
Would this package accept a check of checking for an attribute to imply a deprecated scope?
$node->getAttribute('inDeprecatedScope', false)
I don't know how other frameworks are handling this kind of bridge, I need to look.
The related issue has been merged into 1.11 (#99). So we should be able to use those new scoperesolvers for that right?
Yeah, this can be closed now.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.