-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature request: add psalm type declarations (and push type inference) #1
Comments
Hi Marco, I will give it a try asap :-) Thanks !!! |
Here's a first try: https://psalm.dev/r/a71e6f340c I don't think that it is possible to infer the type yet... |
If you ignore the analysis on the internals, it's working on the inferred types (https://psalm.dev/r/0d396e5142). Specifically: $v = new A(function (string $p) : array { return explode(',', $p); }, 'yadda');
echo $v(); // ERROR: InvalidArgument - 66:6 - Argument 1 of echo expects string, non-empty-list<string> provided |
I just created a PR, it would be nice if you could give a quick review ! |
Issue #1: Add PSALM type declarations.
Thanks @Ocramius and @dannywillems for their help! Tag 1.1.0 is available and this issue can now be closed. |
Not sure if you are interested in this, but it is an interesting exercise, and good added value for downstream consumers.
Given (for example) combinator
A
:This can be achieved via something like:
This is currently tested in (for example) phpunit via some static analysis scripts: https://github.com/sebastianbergmann/phpunit/tree/619868463e06e5072c6e42dbae174d99cdd10fc2/tests/static-analysis
The text was updated successfully, but these errors were encountered: