-
Notifications
You must be signed in to change notification settings - Fork 21
Description
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:
- The base class is not an interface (where it makes sense to have deprecations being contagious) as mentioned in Detecting deprecated methods from an interface #48
- And as mentioned in Test failures with PHPStan dev-master #50 (Test failures with PHPStan dev-master #50 (comment)) when extending a class, the method should not be explicitly deprecated as well but should only do so if
@inheritdocis present. - VSCode does not understand this as deprecated
- The authors of the validation library don't do so either.
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!