mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Allow *bin2hex and *bin2base64 functions to keep non-empty-string type
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")); ```
This commit is contained in:
parent
0b790e0982
commit
4b1adaafec
@ -334,6 +334,22 @@ function fclose(&$stream) : bool
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @template T as string
|
||||
* @param T $string
|
||||
* @return (T is non-empty-string ? non-empty-string : string)
|
||||
*/
|
||||
function sodium_bin2base64(string $string, int $id): string
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @template T as string
|
||||
* @param T $string
|
||||
* @return (T is non-empty-string ? non-empty-string : string)
|
||||
*/
|
||||
function sodium_bin2hex(string $string): string {}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param-out null $string
|
||||
@ -1308,9 +1324,21 @@ function base64_decode(string $string, bool $strict = false) {}
|
||||
* @psalm-pure
|
||||
*
|
||||
* @psalm-flow ($string) -> return
|
||||
* @template T as string
|
||||
* @param T $string
|
||||
* @return (T is non-empty-string ? non-empty-string : string)
|
||||
*/
|
||||
function base64_encode(string $string) : string {}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @template T as string
|
||||
* @param T $string
|
||||
* @return (T is non-empty-string ? non-empty-string : string)
|
||||
*/
|
||||
function bin2hex(string $string): string {}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user