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

exec() incorrectly gives TypeDoesNotContainType error when checking for false return #6195

Closed
bitwise-operators opened this issue Jul 28, 2021 · 1 comment · Fixed by #6196

Comments

@bitwise-operators
Copy link
Contributor

The php exec() function has return type 'string|false', like so many PHP functions.

However, when you check for this return value, Psalm (tested on v4.8) gives
TypeDoesNotContainType - string does not contain false

Demo here:
https://psalm.dev/r/b0213d4c41

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/b0213d4c41
<?php
if (false === exec('ls')) {
    echo 'failed to execute';
}
Psalm output (using commit 7aa5564):

ERROR: TypeDoesNotContainType - 2:5 - string does not contain false

weirdan added a commit to weirdan/psalm that referenced this issue Jul 28, 2021
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.

1 participant