Fix checkCLI call on false return from php_sapi_name()

This commit is contained in:
Clemens Schwaighofer
2022-05-24 13:12:17 +09:00
parent 1e734581d7
commit 5b581c2ed6

View File

@@ -102,7 +102,15 @@ class System
*/
public static function checkCLI(): bool
{
return substr(php_sapi_name(), 0, 3) === 'cli' ? true : false;
return substr(
// if return is false, use empty string
(($sapi_name = php_sapi_name()) === false ?
'' :
$sapi_name
),
0,
3
) === 'cli' ? true : false;
}
}