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

get_headers: array<array-key, mixed> can never contain false #6199

Closed
michabbb opened this issue Jul 28, 2021 · 2 comments · Fixed by #6206
Closed

get_headers: array<array-key, mixed> can never contain false #6199

michabbb opened this issue Jul 28, 2021 · 2 comments · Fixed by #6206
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm internal stubs/callmap

Comments

@michabbb
Copy link

https://psalm.dev/r/c9c058d764

pardon, i do myself hard to understand this error, because the PHP documentation clearly says:

Returns an indexed or associative array with the headers, or false on failure.

what am I missing here ?

thanks for any help!

@psalm-github-bot
Copy link

I found these snippets:

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

$file_headers = @get_headers('https://somethinganything.dev');
$return = ($file_headers!==false && mb_stripos($file_headers[0], '404 Not Found') === false);
echo $return;
Psalm output (using commit 89ee1f1):

ERROR: RedundantCondition - 4:12 - array<array-key, mixed> can never contain false

INFO: PossiblyUndefinedIntArrayOffset - 4:48 - Possibly undefined array offset '0' is risky given expected type 'array-key'. Consider using isset beforehand.

INFO: MixedArgument - 4:48 - Argument 1 of mb_stripos cannot be mixed, expecting string

@weirdan
Copy link
Collaborator

weirdan commented Jul 28, 2021

@orklah orklah added the easy problems Issues that can be fixed without background knowledge of Psalm label Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm internal stubs/callmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants