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

Skip to content

Guard scripts from being run in non-CLI contexts #47777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
// Please update when phpunit needs to be reinstalled with fresh deps:
// Cache-Id: 2021-02-04 11:00 UTC

if ('cli' !== \PHP_SAPI && 'phpdbg' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

error_reporting(-1);

global $argv, $argc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* file that was distributed with this source code.
*/

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

require dirname(__DIR__, 6).'/vendor/autoload.php';

use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\UnusedTagsPassUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* file that was distributed with this source code.
*/

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

$operators = ['not', '!', 'or', '||', '&&', 'and', '|', '^', '&', '==', '===', '!=', '!==', '<', '>', '>=', '<=', 'not in', 'in', '..', '+', '-', '~', '*', '/', '%', 'matches', '**'];
$operators = array_combine($operators, array_map('strlen', $operators));
arsort($operators);
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Intl/Resources/bin/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* file that was distributed with this source code.
*/

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

define('LINE_WIDTH', 75);

define('LINE', str_repeat('-', LINE_WIDTH)."\n");
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Intl/Resources/bin/update-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
use Symfony\Component\Intl\Locale;
use Symfony\Component\Intl\Util\GitRepository;

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

require_once __DIR__.'/common.php';
require_once __DIR__.'/autoload.php';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* file that was distributed with this source code.
*/

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

// load new map
$data = file_get_contents('https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
$new = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* file that was distributed with this source code.
*/

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

$usageInstructions = <<<END

Usage instructions
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/VarDumper/Resources/bin/var-dump-server
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
* file that was distributed with this source code.
*/

if ('cli' !== PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

/**
* Starts a dump server to collect and output dumps on a single place with multiple formats support.
*
Expand Down