-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Support psalm #208
Comments
Nice to see that you decided to go with Psalm! I think this is the best choice for a lib like yours, where templates and I would like to help with the integration, if you don't mind (and if it's really needed...). Can start from the end of the list, to not mess with you. |
@alexeyshockov it would be terrific to collaborate on this topic. I've just pushed my current WIP, would you mind rebasing. Unfortunately it’s going to create a few conflicts, sorry about that. |
@ondrejmirtes Could @phpstan 0.12 also benefit from this work to make this available to even broader user base? |
@jkuchar PHPStan can benefit from generics annotations, not from "pure" or "assert" yet. Instead of assert annotations, right now a TypeSpecifyingExtension has to be written. There are already extensions like that for PHPUnit, for beberlei/assert and webmozart/assert. Of course, an extension like this can be written to interpret these phpDoc annotations but no one did that yet. |
One little thing to add: comment of variable length argument need a fix It should be
|
Hi @lstrojny! Since 3.11.3 Psalm supports /**
* @template A
* @template B
* @template C
* @template D
* @template F
* @template G
* @template H
* @template I
*
* @param callable(A):B $aToB
* @param callable(B):C $bToC
* @param callable(C):D $cToD
* @param callable(D):F $dToF
* @param callable(F):G $fToG
* @param callable(G):H $gToH
* @param callable(H):I $hToI
*
* @return (func_num_args() is 2 ? callable(A):C : (
* func_num_args() is 3 ? callable(A):D : (
* func_num_args() is 4 ? callable(A):F : (
* func_num_args() is 5 ? callable(A):G : (
* func_num_args() is 6 ? callable(A):H : (
* func_num_args() is 7 ? callable(A):I : callable
* ))))))
*/
function compose(
callable $aToB,
callable $bToC,
callable $cToD = null,
callable $dToF = null,
callable $fToG = null,
callable $gToH = null,
callable $hToI = null,
callable ...$others
) {
// impl here
} In this case you can type limited arguments count. Unfortunately you can pass null value instead of one of callable. A similar solution used by rxjs |
@klimick that’s a great idea, thank you! |
Isn't this ready to be merged? (even incomplete) :-) |
Hey, for anyone interested in psalm/phpstan support, there is an alternative to this library that has generics: azjezz/psl. |
Add psalm annotations
@psalm-pure
@psalm-assert
compose
Type specificity
Issues
compose
,curry
, etc.): Mixing templates and types seems to confuse psalm vimeo/psalm#2499The text was updated successfully, but these errors were encountered: