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

UnusedFunctionCall false positive on mail standard extension #10918

Closed
smaddock opened this issue Apr 20, 2024 · 3 comments · Fixed by #10923
Closed

UnusedFunctionCall false positive on mail standard extension #10918

smaddock opened this issue Apr 20, 2024 · 3 comments · Fixed by #10923

Comments

@smaddock
Copy link
Contributor

When calling mail as documented in the PHP manual, Psalm throws an UnusedFunctionCall because the boolean return value is not captured and utilized.

https://psalm.dev/r/79996b7e5c

Copy link

I found these snippets:

https://psalm.dev/r/79996b7e5c
<?php

mail('a@b.c', 'subject line', 'message');
Psalm output (using commit 08afc45):

ERROR: UnusedFunctionCall - 3:1 - The call to mail is not used

@jack-worman
Copy link
Contributor

How do you know if the function worked if you don't check?

if (!mail('a@b.c', 'subject line', 'message')) {
    throw new \Exception('mail() failed.');
}

But anyways, you can fix this problem by submitting a PR which adds mail to the impure function list in dictionaries/ImpureFunctionsList.php.

@smaddock
Copy link
Contributor Author

Not saying one shouldn't check for it, only that the way it is documented in the PHP manual examples don't check for it, so it shouldn't return an UnusedFunctionCall. PR submitted.

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

Successfully merging a pull request may close this issue.

2 participants