How to use a callable as a validator #14800
-
|
I'm working on a framework-level-esque method that deserializes some JSON from a framework-level config store. I want the calling code to be able to specify a validator that would essentially confirm that a strict-shape is being returned. I've tried to simplify it for the playground into this example: https://phpstan.org/r/c2d1ee2a-0fde-4e30-9bd9-032a6fd3cea1 However, I'm running into one major issue: It seems like phpstan can't use conditional returns referencing a callable's parameters. Am I completely off-base here? Should I be doing it some other way? Is it simply not possible with phpstan? I'd really appreciate any suggestions or advice! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Thank you for the idea. This is now possible: phpstan/phpstan-src#5837 |
Beta Was this translation helpful? Give feedback.
Thank you for the idea. This is now possible: phpstan/phpstan-src#5837