Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow flagging a node with an "ignore deprecation" attribute via NodeVisitorAbstract to skip deprecation errors #73

Closed
mglaman opened this issue Jul 20, 2022 · 3 comments

Comments

@mglaman
Copy link
Contributor

mglaman commented Jul 20, 2022

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.

@bbrala
Copy link

bbrala commented Jun 30, 2023

The related issue has been merged into 1.11 (#99). So we should be able to use those new scoperesolvers for that right?

@mglaman
Copy link
Contributor Author

mglaman commented Jun 30, 2023

Yeah, this can be closed now.

@mglaman mglaman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2023
@github-actions
Copy link

github-actions bot commented Aug 1, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants