Skip to content

Commit ad91659

Browse files
committed
bug #41132 [Runtime] don't display the shebang on the CLI (nicolas-grekas)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Runtime] don't display the shebang on the CLI | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #40949 | License | MIT | Doc PR | - Commits ------- 463b2db [Runtime] dont display the shebang on the CLI
2 parents e03ab57 + 463b2db commit ad91659

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Symfony/Component/Runtime/Internal/autoload_runtime.template

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ if (true === (require_once __DIR__.'/autoload.php') || empty($_SERVER['SCRIPT_FI
66
return;
77
}
88

9-
if (!is_object($app = require $_SERVER['SCRIPT_FILENAME'])) {
10-
throw new \TypeError(sprintf('Invalid return value: callable object expected, "%s" returned from "%s".', get_debug_type($app), $_SERVER['SCRIPT_FILENAME']));
9+
if (PHP_VERSION_ID < 80000 && in_array(PHP_SAPI, ['cli', 'phpdbg'], true)) {
10+
ob_start();
11+
$app = require $_SERVER['SCRIPT_FILENAME'];
12+
ob_end_clean();
13+
} else {
14+
$app = require $_SERVER['SCRIPT_FILENAME'];
15+
}
16+
17+
if (!is_object($app)) {
18+
throw new TypeError(sprintf('Invalid return value: callable object expected, "%s" returned from "%s".', get_debug_type($app), $_SERVER['SCRIPT_FILENAME']));
1119
}
1220

1321
$runtime = $_SERVER['APP_RUNTIME'] ?? %runtime_class%;

0 commit comments

Comments
 (0)