-
Notifications
You must be signed in to change notification settings - Fork 667
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
RedundantCondition for config constants #2076
Comments
Why not use a public static const: https://psalm.dev/r/ebd07a3425? |
@muglug Yeah that would probably be better but unfortunately this is something I just can't change. Anyway, I'll just close this. Psalm shouldn't have to deal with badly designed codebases. |
Well then nobody would use it |
Truth is this is horrible for testability and reusability. I'd much rather it weren't this way in our application but it's not something I can change easily. Your config values should probably be coming from a separate file and be distributed through dependency injection or something like similar. |
I don't even see this being useful just for config constants. Most times, the value of a constant doesn't matter. So, if your application breaks when the value of a constant changes to a different value of the same type, that can be a problem. |
Many of our applications look like this:
https://psalm.dev/r/3ed817ceba
I'm aware this isn't great. Constant shouldn't contain variable values. Either way, PHPStan allows defining constants as "dynamic": phpstan/phpstan#1083
Do you see any value in this?
The text was updated successfully, but these errors were encountered: