-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Idea: Support Symfony's deprecation-contracts #47
Comments
Hey Yanick, Could you point me to a concrete code sample? I don't know these symfony things well :-) |
Oh, of course - sorry. I thought you did, my bad! Basically Symfony provides a See https://github.com/symfony/deprecation-contracts. So you'd write If your phpstan extension would support this, all Symfony users would instantly know if they forgot to remove a deprecated feature before releasing a new major version 😎 |
I had a look into it. I don't think this one is doable, as I don't see a way how phpstan should know under which conditions see e.g. the deprecation will only be triggered, when no default protocol is defined in the using app. every deprecation has different semantics under which circumstances it will be triggered. when the codebase contains I will close for now, but feel free to provide more context/feedback in case I missed something |
First of all, thanks for looking into it and spending time on an idea I wrote down! ❤️ Maybe we've misunderstood each other slightly: Yes, you cannot know when a Imagine this: We have a branch named Now we start working on version 9 of our app. So we start a new branch for |
in your example |
Exactly, yes :) |
Hmm do you really use this mechanism to declare deprecations for your own package? I feel the Managing the "todos" of your very own project feels more natural using regular TODO comments..? |
In #86 I have implemented it for composer dependencies but I am not yet sure thats useful either 🥸 |
Love it! ❤️
Of course, we could do this as well. Just means that everywhere where we deprecate an API using |
Released #86 with experimental support. https://github.com/staabm/phpstan-todo-by/releases/tag/0.1.24 please give it a try |
Tried it and it reports all The only problem left before I could create a PR add your extension to our CI workflow is which version it compares it to. I would need a way to determine the version based on the branch name. Why? We have version branches like so:
So my PR would go against
I would need to be able to tell the extension that |
we have a "referenceVersion" for other rules. maybe we should use that when |
In our case this would not work as we have a monorepository, so it should match for multiple package names (which is a general concept that might be interesting because imho monorepos are pretty common). Yes I actually tried |
Maybe you could filter the errors using phpstan ignore rules based on the message? |
Yeah, maybe our use case is too specific so a custom rule would be better anyway 🤔 |
yeah, your use case seems pretty specific. if you can make it work with phpstan ignore patterns and the rule we ship in todo-by, you can go for it. otherwise it might make sense to take inspiration from the rule I have implemented and customize it for your specific needs |
I did, thanks a lot for your help Markus. Should I ever have the pleasure to meet you in person, I'll owe you one 😊 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hey Markus,
Nice extension! I'm not sure if I'll ever need it but the first thing that came to my mind when I read about the version support, was support for Symfony's
trigger_deprecation()
which basically also consists of a package name and a version. So devs wouldn't even need to check the deprecations anymore, your extension would already detect it during static analysis 😉Anyway - just an idea and I thought I'd leave it here.
Happy Holidays!
The text was updated successfully, but these errors were encountered: