The expression $reason of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
29
$msg .= sprintf(' Reason: %s', $reason);
30
}
31
32
return new self($msg);
33
}
34
35
/**
36
* @param string $server Invalid server
37
* @param array $allowed Allowed URL parts
38
*
39
* @return self
40
*/
41
public static function invalidUrlParts($server, array $allowed)
42
{
43
return new self(sprintf(
44
'Server "%s" is invalid. Only %s URL parts are allowed.',
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: