Aggiornato Composer
This commit is contained in:
53
vendor/psy/psysh/src/functions.php
vendored
53
vendor/psy/psysh/src/functions.php
vendored
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -13,6 +13,8 @@ namespace Psy;
|
||||
|
||||
use Psy\ExecutionLoop\ProcessForker;
|
||||
use Psy\VersionUpdater\GitHubChecker;
|
||||
use Psy\VersionUpdater\Installer;
|
||||
use Psy\VersionUpdater\SelfUpdate;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
@@ -23,8 +25,6 @@ if (!\function_exists('Psy\\sh')) {
|
||||
* Command to return the eval-able code to startup PsySH.
|
||||
*
|
||||
* eval(\Psy\sh());
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function sh(): string
|
||||
{
|
||||
@@ -128,7 +128,7 @@ if (!\function_exists('Psy\\info')) {
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
function info(Configuration $config = null)
|
||||
function info(?Configuration $config = null)
|
||||
{
|
||||
static $lastConfig;
|
||||
if ($config !== null) {
|
||||
@@ -155,6 +155,9 @@ if (!\function_exists('Psy\\info')) {
|
||||
|
||||
$config = $lastConfig ?: new Configuration();
|
||||
$configEnv = (isset($_SERVER['PSYSH_CONFIG']) && $_SERVER['PSYSH_CONFIG']) ? $_SERVER['PSYSH_CONFIG'] : false;
|
||||
if ($configEnv === false && \PHP_SAPI === 'cli-server') {
|
||||
$configEnv = \getenv('PSYSH_CONFIG');
|
||||
}
|
||||
|
||||
$shellInfo = [
|
||||
'PsySH version' => Shell::VERSION,
|
||||
@@ -165,6 +168,7 @@ if (!\function_exists('Psy\\info')) {
|
||||
'OS' => \PHP_OS,
|
||||
'default includes' => $config->getDefaultIncludes(),
|
||||
'require semicolons' => $config->requireSemicolons(),
|
||||
'strict types' => $config->strictTypes(),
|
||||
'error logging level' => $config->errorLoggingLevel(),
|
||||
'config file' => [
|
||||
'default config file' => $prettyPath($config->getConfigFile()),
|
||||
@@ -225,6 +229,17 @@ if (!\function_exists('Psy\\info')) {
|
||||
'color mode' => $config->colorMode(),
|
||||
'output decorated' => $config->getOutputDecorated(),
|
||||
'output verbosity' => $config->verbosity(),
|
||||
'output pager' => $config->getPager(),
|
||||
];
|
||||
|
||||
$theme = $config->theme();
|
||||
// @todo show styles (but only if they're different than default?)
|
||||
$output['theme'] = [
|
||||
'compact' => $theme->compact(),
|
||||
'prompt' => $theme->prompt(),
|
||||
'bufferPrompt' => $theme->bufferPrompt(),
|
||||
'replayPrompt' => $theme->replayPrompt(),
|
||||
'returnValue' => $theme->returnValue(),
|
||||
];
|
||||
|
||||
$pcntl = [
|
||||
@@ -336,8 +351,8 @@ if (!\function_exists('Psy\\bin')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (\PHP_VERSION_ID < 70000) {
|
||||
\fwrite(\STDERR, 'PHP 7.0.0 or higher is required. You can set the environment variable PSYSH_IGNORE_ENV=1 to override this restriction and proceed anyway.'.\PHP_EOL);
|
||||
if (\PHP_VERSION_ID < 70400) {
|
||||
\fwrite(\STDERR, 'PHP 7.4.0 or higher is required. You can set the environment variable PSYSH_IGNORE_ENV=1 to override this restriction and proceed anyway.'.\PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -358,12 +373,14 @@ if (!\function_exists('Psy\\bin')) {
|
||||
}
|
||||
|
||||
$usageException = null;
|
||||
$shellIsPhar = Shell::isPhar();
|
||||
|
||||
$input = new ArgvInput();
|
||||
try {
|
||||
$input->bind(new InputDefinition(\array_merge(Configuration::getInputOptions(), [
|
||||
new InputOption('help', 'h', InputOption::VALUE_NONE),
|
||||
new InputOption('version', 'V', InputOption::VALUE_NONE),
|
||||
new InputOption('self-update', 'u', InputOption::VALUE_NONE),
|
||||
|
||||
new InputArgument('include', InputArgument::IS_ARRAY),
|
||||
])));
|
||||
@@ -378,7 +395,7 @@ if (!\function_exists('Psy\\bin')) {
|
||||
}
|
||||
|
||||
// Handle --help
|
||||
if ($usageException !== null || $input->getOption('help')) {
|
||||
if (!isset($config) || $usageException !== null || $input->getOption('help')) {
|
||||
if ($usageException !== null) {
|
||||
echo $usageException->getMessage().\PHP_EOL.\PHP_EOL;
|
||||
}
|
||||
@@ -398,16 +415,27 @@ Options:
|
||||
-c, --config FILE Use an alternate PsySH config file location.
|
||||
--cwd PATH Use an alternate working directory.
|
||||
-V, --version Display the PsySH version.
|
||||
|
||||
EOL;
|
||||
if ($shellIsPhar) {
|
||||
echo <<<EOL
|
||||
-u, --self-update Install a newer version if available.
|
||||
|
||||
EOL;
|
||||
}
|
||||
echo <<<EOL
|
||||
--color Force colors in output.
|
||||
--no-color Disable colors in output.
|
||||
-i, --interactive Force PsySH to run in interactive mode.
|
||||
-n, --no-interactive Run PsySH without interactive input. Requires input from stdin.
|
||||
-r, --raw-output Print var_export-style return values (for non-interactive input)
|
||||
--compact Run PsySH with compact output.
|
||||
-q, --quiet Shhhhhh.
|
||||
-v|vv|vvv, --verbose Increase the verbosity of messages.
|
||||
--yolo Run PsySH without input validation. You don't want this.
|
||||
|
||||
EOL;
|
||||
|
||||
exit($usageException === null ? 0 : 1);
|
||||
}
|
||||
|
||||
@@ -417,6 +445,17 @@ EOL;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Handle --self-update
|
||||
if ($input->getOption('self-update')) {
|
||||
if (!$shellIsPhar) {
|
||||
\fwrite(\STDERR, 'The --self-update option can only be used with with a phar based install.'.\PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
$selfUpdate = new SelfUpdate(new GitHubChecker(), new Installer());
|
||||
$result = $selfUpdate->run($input, $config->getOutput());
|
||||
exit($result);
|
||||
}
|
||||
|
||||
$shell = new Shell($config);
|
||||
|
||||
// Pass additional arguments to Shell as 'includes'
|
||||
|
||||
Reference in New Issue
Block a user