Skip to content
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

Update PHPDoc for the helper clock to add return type #702

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alies-dev
Copy link
Contributor

@alies-dev alies-dev commented May 25, 2024

Add PHPDoc to help static analysers (incl. IDE)

image

(on this screenshot PHPStorm understands that clock() will return \Clockwork\Clockwork instance)

@alies-dev alies-dev changed the title Update helpers.php Update PHPDoc for the helper clock to add return type May 25, 2024
@UlrichEckhardt
Copy link
Contributor

I like type annotations and this PR improves clockwork in that area.

@itsgoingd
Copy link
Owner

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/.

@itsgoingd
Copy link
Owner

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.

@alies-dev
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants