-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
https://phpstan.org/r/51d146e4-ee31-4e29-958d-a8c17c049da7
$urlParts = parse_url($url);
if ($urlParts === false) {
throw new \InvalidArgumentException('Url is not valid');
}
if (isset($urlParts['host'])) {
// This is not redundant
if (isset($urlParts['port'])) {
echo 'Host and port are defined';
}
}Offset 'port' on array('scheme' => string, 'host' => string, 'port' => int, 'user' => string, 'pass' => string, 'path' => string, 'query' => string, 'fragment' => string) in isset() always exists and is not nullable.
I think this is because the return type of parse_url is defined as array()|array(scheme: string, ...)|false which is not correct. The correct type would be array(scheme?: string, ...)|false but I'm not sure if PHPStan is capable of defining optional keys in array literals right now.
This only occurs with bleeding edge. Not sure why.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels