[Runtime] dont display the shebang on the CLI

This commit is contained in:
Nicolas Grekas 2021-05-07 20:11:34 +02:00
parent e03ab57139
commit 463b2db51b

View File

@ -6,8 +6,16 @@ if (true === (require_once __DIR__.'/autoload.php') || empty($_SERVER['SCRIPT_FI
return; return;
} }
if (!is_object($app = require $_SERVER['SCRIPT_FILENAME'])) { if (PHP_VERSION_ID < 80000 && in_array(PHP_SAPI, ['cli', 'phpdbg'], true)) {
throw new \TypeError(sprintf('Invalid return value: callable object expected, "%s" returned from "%s".', get_debug_type($app), $_SERVER['SCRIPT_FILENAME'])); ob_start();
$app = require $_SERVER['SCRIPT_FILENAME'];
ob_end_clean();
} else {
$app = require $_SERVER['SCRIPT_FILENAME'];
}
if (!is_object($app)) {
throw new TypeError(sprintf('Invalid return value: callable object expected, "%s" returned from "%s".', get_debug_type($app), $_SERVER['SCRIPT_FILENAME']));
} }
$runtime = $_SERVER['APP_RUNTIME'] ?? %runtime_class%; $runtime = $_SERVER['APP_RUNTIME'] ?? %runtime_class%;