Skip to content
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

Merged
merged 1 commit into from Aug 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions stubs/CoreGenericFunctions.phpstub
Expand Up @@ -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
Copy link
Contributor

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

Copy link
Collaborator

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

* @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
Expand Down Expand Up @@ -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
*
Expand Down