Skip to content

Extending a deprecated class causes inheriting method to be deprecated #171

@Csardelacal

Description

@Csardelacal

I think this is a regression. I noticed this while working with respect/validation. Here's a playground link:

https://phpstan.org/r/93991ac0-7017-4424-987a-73741c50be22

In my case, the library moved certain aspects of it's validation from one class to another.

From: https://github.com/Respect/Validation/blob/57fd6f52ecf959ba3aa830533c9555eb27fd213c/library/Rules/AllOf.php#L25
To: https://github.com/Respect/Validation/blob/57fd6f52ecf959ba3aa830533c9555eb27fd213c/library/Validator.php#L37

And they encourage to migrate by changing the code from / to:

V::create()->addRule(new Rule)->assert($data);
V::create(new Rule)->assert($data)

This causes the error Call to deprecated method assert() of class Respect\Validation\Validator. I think this is not intended behavior when I read the following:

What happens

I get an error telling me that the method replacing the old one is deprecated.

What I expected to happen

I think the code in the playground should validate just fine. I think it would be a different story if the code had an @inheritdoc tag or was actually invoking parent::sayHello() (I think that should be an error in the child class since my code is not directly calling it).

How PHPStan is making my life better today

I'm migrating a really old and extensive codebase from PHP7 to PHP8 right now, and PHPStan (and other libs like PHPUnit) are giving me a lot of confidence in the code I am refactoring and adjusting. Thank you so much for your work!

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