You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove static from GraphQL\Validator\Rules\ValuesOfCorrectType #851
A lot of static methods are used in ValuesOfCorrectType, but when I take a closer look I can't see why. There seems to be no added benefit in having these static. Would it be possible to remove all the static usage from this class?
The reason I ask is because I want to extend it in order to change the way some error messages are created. This feels related to #711, but I want to do more than a simple string replacement.
So the only reason they are static is because of tests?
I just named one reason, there may be many.
Another one I can think of right now is that static methods are generally easier to reason about; one does (generally) not have to worry about state with them.
Then replacing self with static would also work for my case.
Yes. Accepting PRs, but preferrably one that opens up all validation rules for extensibility to ensure consistency.
Activity
spawnia commentedon Apr 26, 2021
Those methods can be called without class instantiation, this is done from tests. How would removing
staticimprove extensibility?I think the deciciding difference is in how those methods are called.
self::method()prevents overrides, whilestatic::method()works.wimski commentedon Apr 26, 2021
So the only reason they are static is because of tests?
Then replacing
selfwithstaticwould also work for my case.spawnia commentedon Apr 26, 2021
I just named one reason, there may be many.
Another one I can think of right now is that static methods are generally easier to reason about; one does (generally) not have to worry about state with them.
Yes. Accepting PRs, but preferrably one that opens up all validation rules for extensibility to ensure consistency.