-
Notifications
You must be signed in to change notification settings - Fork 660
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
Allow *bin2hex and *bin2base64 functions to keep non-empty-string type #8431
Conversation
I believe the |
Hum maybe? I took the same approach than for the |
Well, if they're already there I guess this is fine then. Maybe I'll get around to moving them to a separate extension stub for Psalm 5. |
Those functions should not return a string when they receive a non-empty-string in input. The following example is expected to work: ```php <?php /** * @param non-empty-string $i */ function takesNonEmptyString(string $i): void { echo $i; } takesNonEmptyString(bin2hex("a")); takesNonEmptyString(base64_encode("a")); ```
b466a96
to
4b1adaa
Compare
Thanks! |
|
||
/** | ||
* @psalm-pure | ||
* @template T as string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a headsup from the review in phpstan. we don't need a template in phpstan for this case, see phpstan/phpstan-src#1664
maybe thats also the case for psalm and this can be simplified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, same on Psalm, but stubs are transparent for users so it doesn't really matters
Those functions should not return a string when they receive a non-empty-string in input.
The following example is expected to work:
https://psalm.dev/r/0d5b2b3965