/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Console
NameSizeModeActions
Command/-0755rm
Exception/-0755rm
Arguments.php38580644editdlrm
BaseCommand.php80360644editdlrm
Command.php1760644editdlrm
CommandCollection.php72110644editdlrm
CommandCollectionAwareInterface.php10220644editdlrm
CommandFactory.php14310644editdlrm
CommandFactoryInterface.php9960644editdlrm
CommandInterface.php16980644editdlrm
CommandRunner.php125360644editdlrm
CommandScanner.php48280644editdlrm
composer.json11730644editdlrm
ConsoleErrorHandler.php2340644editdlrm
ConsoleInput.php28750644editdlrm
ConsoleInputArgument.php54920644editdlrm
ConsoleInputOption.php81320644editdlrm
ConsoleInputSubcommand.php39040644editdlrm
ConsoleIo.php206420644editdlrm
ConsoleOptionParser.php303260644editdlrm
ConsoleOutput.php97170644editdlrm
Helper.php16750644editdlrm
HelperRegistry.php33460644editdlrm
HelpFormatter.php72160644editdlrm
README.md33210644editdlrm
Shell.php293530644editdlrm
ShellDispatcher.php122240644editdlrm
TaskRegistry.php30050644editdlrm
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php (12224B)
args = (array)$args; $this->addShortPluginAliases(); if ($bootstrap) { $this->_initEnvironment(); } } /** * Add an alias for a shell command. * * Aliases allow you to call shells by alternate names. This is most * useful when dealing with plugin shells that you want to have shorter * names for. * * If you re-use an alias the last alias set will be the one available. * * ### Usage * * Aliasing a shell named ClassName: * * ``` * $this->alias('alias', 'ClassName'); * ``` * * Getting the original name for a given alias: * * ``` * $this->alias('alias'); * ``` * * @param string $short The new short name for the shell. * @param string|null $original The original full name for the shell. * @return string|null The aliased class name, or null if the alias does not exist */ public static function alias(string $short, ?string $original = null): ?string { $short = Inflector::camelize($short); if ($original) { static::$_aliases[$short] = $original; } return static::$_aliases[$short] ?? null; } /** * Clear any aliases that have been set. * * @return void */ public static function resetAliases(): void { static::$_aliases = []; } /** * Run the dispatcher * * @param array $argv The argv from PHP * @param array $extra Extra parameters * @return int The exit code of the shell process. */ public static function run(array $argv, array $extra = []): int { $dispatcher = new ShellDispatcher($argv); return $dispatcher->dispatch($extra); } /** * Defines current working environment. * * @return void * @throws \Cake\Core\Exception\Exception */ protected function _initEnvironment(): void { $this->_bootstrap(); if (function_exists('ini_set')) { ini_set('html_errors', '0'); ini_set('implicit_flush', '1'); ini_set('max_execution_time', '0'); } $this->shiftArgs(); } /** * Initializes the environment and loads the CakePHP core. * * @return void */ protected function _bootstrap() { if (!Configure::read('App.fullBaseUrl')) { Configure::write('App.fullBaseUrl', 'http://localhost'); } } /** * Dispatches a CLI request * * Converts a shell command result into an exit code. Null/True * are treated as success. All other return values are an error. * * @param array $extra Extra parameters that you can manually pass to the Shell * to be dispatched. * Built-in extra parameter is : * * - `requested` : if used, will prevent the Shell welcome message to be displayed * @return int The cli command exit code. 0 is success. */ public function dispatch(array $extra = []): int { try { $result = $this->_dispatch($extra); } catch (StopException $e) { $code = $e->getCode(); return (int)$code; } if ($result === null || $result === true) { /** @psalm-suppress DeprecatedClass */ return Shell::CODE_SUCCESS; } if (is_int($result)) { return $result; } /** @psalm-suppress DeprecatedClass */ return Shell::CODE_ERROR; } /** * Dispatch a request. * * @param array $extra Extra parameters that you can manually pass to the Shell * to be dispatched. * Built-in extra parameter is : * * - `requested` : if used, will prevent the Shell welcome message to be displayed * @return bool|int|null * @throws \Cake\Console\Exception\MissingShellMethodException */ protected function _dispatch(array $extra = []) { $shellName = $this->shiftArgs(); if (!$shellName) { $this->help(); return false; } if (in_array($shellName, ['help', '--help', '-h'], true)) { $this->help(); return true; } if (in_array($shellName, ['version', '--version'], true)) { $this->version(); return true; } $shell = $this->findShell($shellName); $shell->initialize(); return $shell->runCommand($this->args, true, $extra); } /** * For all loaded plugins, add a short alias * * This permits a plugin which implements a shell of the same name to be accessed * Using the shell name alone * * @return array the resultant list of aliases */ public function addShortPluginAliases(): array { $plugins = Plugin::loaded(); $io = new ConsoleIo(); $task = new CommandTask($io); $io->setLoggers(false); $list = $task->getShellList() + ['app' => []]; $fixed = array_flip($list['app']) + array_flip($list['CORE']); $aliases = $others = []; foreach ($plugins as $plugin) { if (!isset($list[$plugin])) { continue; } foreach ($list[$plugin] as $shell) { $aliases += [$shell => $plugin]; if (!isset($others[$shell])) { $others[$shell] = [$plugin]; } else { $others[$shell] = array_merge($others[$shell], [$plugin]); } } } foreach ($aliases as $shell => $plugin) { if (isset($fixed[$shell])) { Log::write( 'debug', "command '$shell' in plugin '$plugin' was not aliased, conflicts with another shell", ['shell-dispatcher'] ); continue; } $other = static::alias($shell); if ($other) { $other = $aliases[$shell]; if ($other !== $plugin) { Log::write( 'debug', "command '$shell' in plugin '$plugin' was not aliased, conflicts with '$other'", ['shell-dispatcher'] ); } continue; } if (isset($others[$shell])) { $conflicts = array_diff($others[$shell], [$plugin]); if (count($conflicts) > 0) { $conflictList = implode("', '", $conflicts); Log::write( 'debug', "command '$shell' in plugin '$plugin' was not aliased, conflicts with '$conflictList'", ['shell-dispatcher'] ); } } static::alias($shell, "$plugin.$shell"); } return static::$_aliases; } /** * Get shell to use, either plugin shell or application shell * * All paths in the loaded shell paths are searched, handles alias * dereferencing * * @param string $shell Optionally the name of a plugin * @return \Cake\Console\Shell A shell instance. * @throws \Cake\Console\Exception\MissingShellException when errors are encountered. */ public function findShell(string $shell): Shell { $className = $this->_shellExists($shell); if (!$className) { $shell = $this->_handleAlias($shell); $className = $this->_shellExists($shell); } if (!$className) { throw new MissingShellException([ 'class' => $shell, ]); } return $this->_createShell($className, $shell); } /** * If the input matches an alias, return the aliased shell name * * @param string $shell Optionally the name of a plugin or alias * @return string Shell name with plugin prefix */ protected function _handleAlias(string $shell): string { $aliased = static::alias($shell); if ($aliased) { $shell = $aliased; } $class = array_map('Cake\Utility\Inflector::camelize', explode('.', $shell)); return implode('.', $class); } /** * Check if a shell class exists for the given name. * * @param string $shell The shell name to look for. * @return string|null Either the classname or null. */ protected function _shellExists(string $shell): ?string { $class = App::className($shell, 'Shell', 'Shell'); if ($class) { return $class; } return null; } /** * Create the given shell name, and set the plugin property * * @param string $className The class name to instantiate * @param string $shortName The plugin-prefixed shell name * @return \Cake\Console\Shell A shell instance. */ protected function _createShell(string $className, string $shortName): Shell { [$plugin] = pluginSplit($shortName); /** @var \Cake\Console\Shell $instance */ $instance = new $className(); $instance->plugin = trim((string)$plugin, '.'); return $instance; } /** * Removes first argument and shifts other arguments up * * @return mixed Null if there are no arguments otherwise the shifted argument */ public function shiftArgs() { return array_shift($this->args); } /** * Shows console help. Performs an internal dispatch to the CommandList Shell * * @return void */ public function help(): void { trigger_error( 'Console help cannot be generated from Shell classes anymore. ' . 'Upgrade your application to use Cake\Console\CommandRunner instead.', E_USER_WARNING ); } /** * Prints the currently installed version of CakePHP. Performs an internal dispatch to the CommandList Shell * * @return void */ public function version(): void { trigger_error( 'Version information cannot be generated from Shell classes anymore. ' . 'Upgrade your application to use Cake\Console\CommandRunner instead.', E_USER_WARNING ); } }