The expression $workingDirectory 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...
44
1
$process->setWorkingDirectory($workingDirectory);
45
}
46
47
2
$process->run();
48
2
}
49
50
2
private function ensureDirectoryExists(string $directory)
51
{
52
2
if (!is_dir($directory)) {
53
1
throw new \Exception(
54
1
sprintf('Directory "%s" was not found.', $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: