From 463b2db51b9f471bbd1a0ec893314421f37e7b5b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 7 May 2021 20:11:34 +0200 Subject: [PATCH] [Runtime] dont display the shebang on the CLI --- .../Runtime/Internal/autoload_runtime.template | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Runtime/Internal/autoload_runtime.template b/src/Symfony/Component/Runtime/Internal/autoload_runtime.template index e6acb1eed6a16..71ecd06d99b3d 100644 --- a/src/Symfony/Component/Runtime/Internal/autoload_runtime.template +++ b/src/Symfony/Component/Runtime/Internal/autoload_runtime.template @@ -6,8 +6,16 @@ if (true === (require_once __DIR__.'/autoload.php') || empty($_SERVER['SCRIPT_FI return; } -if (!is_object($app = require $_SERVER['SCRIPT_FILENAME'])) { - throw new \TypeError(sprintf('Invalid return value: callable object expected, "%s" returned from "%s".', get_debug_type($app), $_SERVER['SCRIPT_FILENAME'])); +if (PHP_VERSION_ID < 80000 && in_array(PHP_SAPI, ['cli', 'phpdbg'], true)) { + 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%;