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

urlencode(non-empty-string) returns non-empty-string #11184

Open
mathroc opened this issue Dec 13, 2024 · 3 comments
Open

urlencode(non-empty-string) returns non-empty-string #11184

mathroc opened this issue Dec 13, 2024 · 3 comments

Comments

@mathroc
Copy link
Contributor

mathroc commented Dec 13, 2024

Hi!

is it ok to update the callmap to make Psalm understand that urlencode(non-empty-string) will always return a non-empty-string ?

I guess there are many over functions like that and I'm not planning to do all of them though 😅

Copy link

Hey @mathroc, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.

@mathroc
Copy link
Contributor Author

mathroc commented Dec 13, 2024

Copy link

I found these snippets:

https://psalm.dev/r/b603b51a2c
<?php

/**
 * @param non-empty-string $input
 * @return non-empty-string
 */
function f(string $input): string
{
    return urlencode($input);
}
Psalm output (using commit a9b5291):

INFO: LessSpecificReturnStatement - 9:12 - The type 'string' is more general than the declared return type 'non-empty-string' for f

INFO: MoreSpecificReturnType - 5:12 - The declared return type 'non-empty-string' for f is more specific than the inferred return type 'string'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant