Skip to content

Fail on method calls to deprecated classes #85

Description

@gms8994

If a class is deprecated, I would expect that any calls to methods in that deprecated class should also trigger a deprecation message.

For example, a change that I implemented locally in CallToDeprecatedMethodRule:

if ($classReflection->isDeprecated()) {
    $description = $methodReflection->getDeprecatedDescription();
    if ($description === null) {
        return [sprintf(
            'Call to method %s() of deprecated class %s.',
            $methodReflection->getName(),
            $methodReflection->getDeclaringClass()->getName()
        )];
    }

    return [sprintf(
        "Call to method %s() of deprecated class %s:\n%s",
        $methodReflection->getName(),
        $methodReflection->getDeclaringClass()->getName(),
        $description
    )];
}

Though maybe this makes more sense as a separate rule within this library, it works well enough for my needs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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