The expression $path of type null|string 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...
18
$this->setPath($path);
19
}
20
}
21
22
/**
23
* @param string $path
24
* @return $this
25
* @throws PathNotFoundException
26
*/
27
public function setPath($path)
28
{
29
$path = realpath($path);
30
if (!is_dir($path)) {
31
throw new PathNotFoundException("Config path ({$path}) is not a valid directory");
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: