Skip to content

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

Closed as not planned
@mglaman

Description

@mglaman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions