Allow *bin2hex and *bin2base64 functions to keep non-empty-string type#8431
Allow *bin2hex and *bin2base64 functions to keep non-empty-string type#8431AndrolGenhald merged 1 commit intovimeo:4.xfrom
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.
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.
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