Open alies-dev opened 6 months ago
I like type annotations and this PR improves clockwork in that area.
It would be cool, if instead of returning mixed
, we could return the type of the first argument. I wonder if PHPStorm supports the @template
syntax - https://psalm.dev/docs/annotating_code/templated_annotations/.
So the good news is, we can probably write the PHPDoc in a way, where it always returns correct type instead of just mixed
.
Bad news is, the conditional returns are currently broken in PHPStorm (https://youtrack.jetbrains.com/issue/WI-78351/Type-not-correctly-inferred-from-phpstan-psalm-conditional-generic-return-type), so I have to wait until they've fixed it, before I can experiment with it further.
Hey @itsgoingd It's great to see an activity on this thread! I would like to add that conditional returns work perfectly in PHPStan and Psalm, so I think there is still a value to add them
Add PHPDoc to help static analysers (incl. IDE)
(on this screenshot PHPStorm understands that clock() will return \Clockwork\Clockwork instance)