Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01dc108

Browse files
committed
minor #47778 Guard scripts from being run in non-CLI contexts (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- Guard scripts from being run in non-CLI contexts | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Same as #47777 but for 5.4. I checked 6.x and we didn't add more scripts there. Commits ------- 9335c81 Guard scripts from being run in non-CLI contexts
2 parents ac0b415 + 9335c81 commit 01dc108

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/Symfony/Component/ErrorHandler/Resources/bin/extract-tentative-return-types.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13+
if ('cli' !== \PHP_SAPI) {
14+
throw new Exception('This script must be run from the command line.');
15+
}
16+
1317
// Run from the root of the php-src repository, this script generates
1418
// a table with all the methods that have a tentative return type.
1519
//

src/Symfony/Component/ErrorHandler/Resources/bin/patch-type-declarations

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13+
if ('cli' !== \PHP_SAPI) {
14+
throw new Exception('This script must be run from the command line.');
15+
}
16+
1317
if (\in_array('-h', $argv) || \in_array('--help', $argv)) {
1418
echo implode(PHP_EOL, [
1519
' Patches type declarations based on "@return" PHPDoc and triggers deprecations for',

src/Symfony/Component/String/Resources/bin/update-data.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
use Symfony\Component\String\Resources\WcswidthDataGenerator;
1313

14+
if ('cli' !== \PHP_SAPI) {
15+
throw new Exception('This script must be run from the command line.');
16+
}
17+
1418
error_reporting(\E_ALL);
1519

1620
set_error_handler(static function (int $type, string $msg, string $file, int $line): void {

src/Symfony/Component/Yaml/Resources/bin/yaml-lint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13+
if ('cli' !== \PHP_SAPI) {
14+
throw new Exception('This script must be run from the command line.');
15+
}
16+
1317
/**
1418
* Runs the Yaml lint command.
1519
*

0 commit comments

Comments
 (0)