8000 Guard scripts from being run in non-CLI contexts · enumag/symfony@edaea64 · GitHub
[go: up one dir, main page]

Skip to content

Commit edaea64

Browse files
Guard scripts from being run in non-CLI contexts
1 parent 25c0a20 commit edaea64

File tree

8 files changed

+32
-0
lines changed

8 files changed

+32
-0
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
// Please update when phpunit needs to be reinstalled with fresh deps:
1313
// Cache-Id: 2021-02-04 11:00 UTC
1414

15+
if ('cli' !== \PHP_SAPI && 'phpdbg' !== \PHP_SAPI) {
16+
throw new Exception('This script must be run from the command line.');
17+
}
18+
1519
error_reporting(-1);
1620

1721
global $argv, $argc;

src/Symfony/Bundle/FrameworkBundle/Resources/bin/check-unused-known-tags.php

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

12+
if ('cli' !== \PHP_SAPI) {
13+
throw new Exception('This script must be run from the command line.');
14+
}
15+
1216
require dirname(__DIR__, 6).'/vendor/autoload.php';
1317

1418
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\UnusedTagsPassUtils;

src/Symfony/Component/ExpressionLanguage/Resources/bin/generate_operator_regex.php

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

12+
if ('cli' !== \PHP_SAPI) {
13+
throw new Exception('This script must be run from the command line.');
14+
}
15+
1216
$operators = ['not', '!', 'or', '||', '&&', 'and', '|', '^', '&', '==', '===', '!=', '!==', '<', '>', '>=', '<=', 'not in', 'in', '..', '+', '-', '~', '*', '/', '%', 'matches', '**'];
1317
$operators = array_combine($operators, array_map('strlen', $operators));
1418
arsort($operators);

src/Symfony/Component/Intl/Resources/bin/common.php

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

12+
if ('cli' !== \PHP_SAPI) {
13+
throw new Exception('This script must be run from the command line.');
14+
}
15+
1216
define('LINE_WIDTH', 75);
1317

1418
define('LINE', str_repeat('-', LINE_WIDTH)."\n");

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
use Symfony\Component\Intl\Locale;
2424
use Symfony\Component\Intl\Util\GitRepository;
2525

26+
if ('cli' !== \PHP_SAPI) {
27+
throw new Exception('This script must be run from the command line.');
28+
}
29+
2630
require_once __DIR__.'/common.php';
2731
require_once __DIR__.'/autoload.php';
2832

src/Symfony/Component/Mime/Resources/bin/update_mime_types.php

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

12+
if ('cli' !== \PHP_SAPI) {
13+
throw new Exception('This script must be run from the command line.');
14+
}
15+
1216
// load new map
1317
$data = file_get_contents('https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
1418
$new = [];

src/Symfony/Component/Translation/Resources/bin/translation-status.php

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

12+
if ('cli' !== \PHP_SAPI) {
13+
throw new Exception('This script must be run from the command line.');
14+
}
15+
1216
$usageInstructions = <<<END
1317
1418
Usage instructions

src/Symfony/Component/VarDumper/Resources/bin/var-dump-server

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
* Starts a dump server to collect and output dumps on a single place with multiple formats support.
1519
*

0 commit comments

Comments
 (0)
0