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
Add a way to ignore/override a stub from an extension #10906
Comments
This feature request sometimes come back around and is asked again, but I maintain the opinion that there should still be just a single stub for each symbol, and it should be correct. There shouldn't be a reason for two stub files of the same symbol to exist. What we might be able to do is to merge two stubs of the same class if there's no overlap between the overriden methods, if there's no conflict essentially. |
I agree that "it should", but IMHO, it's in a world where
If an extension is unmaintained and provide lot of useful stub but also an old stub, there is no easy way to exclude the stub for instance. Same might happen if someone sent a PR for a stub non wanted by every one (for instance people might be tired of literal-string issues or benevolent union or list<array> from doctrine)... In the same way there is
I would have find useful to have
because the |
I'm still not convinced :)
Then you should fork it. Using unmaintained software is going to bring you problems sooner or later anyway.
For that there's ignoring errors. But as I said, merging mutliple class stubs with not-overlapping methods might be possible. |
Stub sometimes provide a way to ignore all issue in one. I'll give you a personal (opinionated) example.
"Error: foo should return In the same way the issue can occur with
because the phpdoc is But I clearly understand it's not how you want stub to be used... ^^' |
+1 for merging and overriding methods. One of the case the larastan - it is not 100% full, so sometimes it can be useful. Another related edge case are extensions - there is no way disable unwanted :( See #10410 (I use custom helper to remove unwanted rules...) |
Extensions can offer options to disable services, if it's a valid use-case (and not just a workaround to a larger issue). Look at phpstan-strict-rules config where everything can be turned off: https://github.com/phpstan/phpstan-strict-rules/blob/1.6.x/rules.neon |
Yep, but usually they are not :( |
Feature request
When two stubs are declaring the same class we're ending with
Class Foo declared multiple times:
which is not ignorable.I see many use case
Notice both of this situation are easy to happen because when we're defining a stub, all the class need to be defined so we're often ending creating "empty stub" like https://github.com/phpstan/phpstan-symfony/blob/1.4.x/stubs/Symfony/Component/Console/Exception/ExceptionInterface.stub ; and two different lib can ending defining the same "empty stub" (or one of them might not be empty).
It should be useful to have something like a way to ignore/prefer a stub.
Did PHPStan help you today? Did it make you happy in any way?
Yes, PHPStan is great.
The text was updated successfully, but these errors were encountered: