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

empty() check ignored after fgetcsv() #3910

Closed
thbley opened this issue Jul 30, 2020 · 2 comments
Closed

empty() check ignored after fgetcsv() #3910

thbley opened this issue Jul 30, 2020 · 2 comments

Comments

@thbley
Copy link
Contributor

thbley commented Jul 30, 2020

psalm 3.12.3 gives: Argument 1 of strval cannot be null, possibly null value provided
psalm 3.12.2 gives: no error

https://psalm.dev/r/eb1c5f9e86

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/eb1c5f9e86
<?php
$headers = fgetcsv(fopen('test.txt', 'r'));
if (empty($headers)) {
    throw new Exception('invalid headers');
}
print_r(array_map('strval', $headers));
Psalm output (using commit 5635070):

ERROR: PossiblyNullArgument - 6:29 - Argument 1 of strval cannot be null, possibly null value provided

@muglug muglug closed this as completed in ad1920c Jul 30, 2020
@muglug
Copy link
Collaborator

muglug commented Jul 30, 2020

technically fgetcsv can return [null] which passes the empty check, but in reality that's incredibly rare.

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

2 participants