diff --git a/system/Common.php b/system/Common.php index 32943189b56b..bf91834ac0b1 100644 --- a/system/Common.php +++ b/system/Common.php @@ -643,16 +643,7 @@ function helper($filenames) */ function is_cli(): bool { - if (defined('STDIN')) { - return true; - } - - if (! isset($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']) && isset($_SERVER['argv']) && count($_SERVER['argv']) > 0) { - return true; - } - - // if source of request is from CLI, the `$_SERVER` array will not populate this key - return ! isset($_SERVER['REQUEST_METHOD']); + return in_array(PHP_SAPI, ['cli', 'phpdbg'], true); } }