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

False positive with base64_decode() #10052

Closed
OwnerOfThisIsle opened this issue Jul 26, 2023 · 4 comments
Closed

False positive with base64_decode() #10052

OwnerOfThisIsle opened this issue Jul 26, 2023 · 4 comments

Comments

@OwnerOfThisIsle
Copy link

https://psalm.dev/r/1dbb7e9f9f

<?php
$encryptedString = "";
$decryptedString = base64_decode($encryptedString);
if ($decryptedString === false) {
    // throw some error
}

will lead to:
ERROR: [DocblockTypeContradiction](https://psalm.dev/155) - 4:5 - string does not contain false

I think base64_decode() can return string|false, so I do not understand why psalm is complaining here.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/1dbb7e9f9f
<?php
$encryptedString = "";
$decryptedString = base64_decode($encryptedString);
if ($decryptedString === false) {
    // throw some error
}
Psalm output (using commit be82c3a):

ERROR: DocblockTypeContradiction - 4:5 - string does not contain false

@OwnerOfThisIsle
Copy link
Author

I just found
#9832

But after reading the php manual page for base64_decode I am still not sure, if there might be other reasons for the function to return false, even when not in strict mode.

@ygottschalk
Copy link
Contributor

@weirdan
Copy link
Collaborator

weirdan commented Jul 26, 2023

As discussed, not a false positive.

@weirdan weirdan closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2023
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

3 participants