Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Psy; use Psy\Exception\DeprecatedException; use Psy\Exception\RuntimeExce..

Decoded Output download

<?php
 namespace Psy; use Psy\Exception\DeprecatedException; use Psy\Exception\RuntimeException; use Psy\ExecutionLoop\ProcessForker; use Psy\Output\OutputPager; use Psy\Output\ShellOutput; use Psy\Output\Theme; use Psy\TabCompletion\AutoCompleter; use Psy\VarDumper\Presenter; use Psy\VersionUpdater\Checker; use Psy\VersionUpdater\GitHubChecker; use Psy\VersionUpdater\IntervalChecker; use Psy\VersionUpdater\NoopChecker; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Configuration { const COLOR_MODE_AUTO = "auto"; const COLOR_MODE_FORCED = "forced"; const COLOR_MODE_DISABLED = "disabled"; const INTERACTIVE_MODE_AUTO = "auto"; const INTERACTIVE_MODE_FORCED = "forced"; const INTERACTIVE_MODE_DISABLED = "disabled"; const VERBOSITY_QUIET = "quiet"; const VERBOSITY_NORMAL = "normal"; const VERBOSITY_VERBOSE = "verbose"; const VERBOSITY_VERY_VERBOSE = "very_verbose"; const VERBOSITY_DEBUG = "debug"; private static $AVAILABLE_OPTIONS = array("codeCleaner", "colorMode", "configDir", "dataDir", "defaultIncludes", "eraseDuplicates", "errorLoggingLevel", "forceArrayIndexes", "formatterStyles", "historyFile", "historySize", "interactiveMode", "manualDbFile", "pager", "prompt", "rawOutput", "requireSemicolons", "runtimeDir", "startupMessage", "strictTypes", "theme", "updateCheck", "useBracketedPaste", "usePcntl", "useReadline", "useTabCompletion", "useUnicode", "verbosity", "warnOnMultipleConfigs", "yolo"); private $defaultIncludes; private $configDir; private $dataDir; private $runtimeDir; private $configFile; private $historyFile; private $historySize; private $eraseDuplicates; private $manualDbFile; private $hasReadline; private $useReadline; private $useBracketedPaste; private $hasPcntl; private $usePcntl; private $newCommands = array(); private $pipedInput; private $pipedOutput; private $rawOutput = false; private $requireSemicolons = false; private $strictTypes = false; private $useUnicode; private $useTabCompletion; private $newMatchers = array(); private $errorLoggingLevel = \E_ALL; private $warnOnMultipleConfigs = false; private $colorMode = self::COLOR_MODE_AUTO; private $interactiveMode = self::INTERACTIVE_MODE_AUTO; private $updateCheck; private $startupMessage; private $forceArrayIndexes = false; private $formatterStyles = array(); private $verbosity = self::VERBOSITY_NORMAL; private $yolo = false; private $theme; private $readline; private $output; private $shell; private $cleaner; private $pager; private $manualDb; private $presenter; private $autoCompleter; private $checker; private $prompt; private $configPaths; public function __construct(array $config = array()) { $this->configPaths = new ConfigPaths(); if (isset($config["configFile"])) { $this->configFile = $config["configFile"]; } elseif (isset($_SERVER["PSYSH_CONFIG"]) && $_SERVER["PSYSH_CONFIG"]) { $this->configFile = $_SERVER["PSYSH_CONFIG"]; } elseif (\PHP_SAPI === "cli-server" && ($configFile = \getenv("PSYSH_CONFIG"))) { $this->configFile = $configFile; } if (isset($config["baseDir"])) { $msg = "The 'baseDir' configuration option is deprecated; " . "please specify 'configDir' and 'dataDir' options instead"; throw new DeprecatedException($msg); } unset($config["configFile"], $config["baseDir"]); $this->loadConfig($config); $this->init(); } public static function fromInput(InputInterface $input) : self { $config = new self(array("configFile" => self::getConfigFileFromInput($input))); if (self::getOptionFromInput($input, array("color", "ansi"))) { $config->setColorMode(self::COLOR_MODE_FORCED); } elseif (self::getOptionFromInput($input, array("no-color", "no-ansi"))) { $config->setColorMode(self::COLOR_MODE_DISABLED); } if ($verbosity = self::getVerbosityFromInput($input)) { $config->setVerbosity($verbosity); } if (self::getOptionFromInput($input, array("interactive", "interaction"), array("-a", "-i"))) { $config->setInteractiveMode(self::INTERACTIVE_MODE_FORCED); } elseif (self::getOptionFromInput($input, array("no-interactive", "no-interaction"), array("-n"))) { $config->setInteractiveMode(self::INTERACTIVE_MODE_DISABLED); } if (self::getOptionFromInput($input, array("compact"))) { $config->setTheme("compact"); } if (!$config->getInputInteractive()) { if (self::getOptionFromInput($input, array("raw-output"), array("-r"))) { $config->setRawOutput(true); } } if (self::getOptionFromInput($input, array("yolo"))) { $config->setYolo(true); } return $config; } private static function getConfigFileFromInput(InputInterface $input) { if ($input->hasOption("config")) { return $input->getOption("config"); } return $input->getParameterOption("--config", null, true) ?: $input->getParameterOption("-c", null, true); } private static function getOptionFromInput(InputInterface $input, array $names, array $otherParams = array()) : bool { foreach ($names as $name) { if ($input->hasOption($name) && $input->getOption($name)) { return true; } } foreach ($names as $name) { $otherParams[] = "--" . $name; } foreach ($otherParams as $name) { if ($input->hasParameterOption($name, true)) { return true; } } return false; } private static function getVerbosityFromInput(InputInterface $input) { if (self::getOptionFromInput($input, array("quiet"), array("-q"))) { return self::VERBOSITY_QUIET; } if ($input->hasOption("verbose") && $input->getOption("verbose") !== true) { switch ($input->getOption("verbose")) { case "-1": return self::VERBOSITY_QUIET; case "0": return self::VERBOSITY_NORMAL; case "1": case null: return self::VERBOSITY_VERBOSE; case "2": case "v": return self::VERBOSITY_VERY_VERBOSE; case "3": case "vv": return self::VERBOSITY_DEBUG; default: return; } } if ($input->hasParameterOption("--verbose=-1", true) || $input->getParameterOption("--verbose", false, true) === "-1") { return self::VERBOSITY_QUIET; } if ($input->hasParameterOption("--verbose=0", true) || $input->getParameterOption("--verbose", false, true) === "0") { return self::VERBOSITY_NORMAL; } if ($input->hasParameterOption("-vvv", true) || $input->hasParameterOption("--verbose=3", true) || $input->getParameterOption("--verbose", false, true) === "3") { return self::VERBOSITY_DEBUG; } if ($input->hasParameterOption("-vv", true) || $input->hasParameterOption("--verbose=2", true) || $input->getParameterOption("--verbose", false, true) === "2") { return self::VERBOSITY_VERY_VERBOSE; } if ($input->hasParameterOption("-v", true) || $input->hasParameterOption("--verbose=1", true) || $input->hasParameterOption("--verbose", true)) { return self::VERBOSITY_VERBOSE; } } public static function getInputOptions() : array { return array(new InputOption("config", "c", InputOption::VALUE_REQUIRED, "Use an alternate PsySH config file location."), new InputOption("cwd", null, InputOption::VALUE_REQUIRED, "Use an alternate working directory."), new InputOption("color", null, InputOption::VALUE_NONE, "Force colors in output."), new InputOption("no-color", null, InputOption::VALUE_NONE, "Disable colors in output."), new InputOption("ansi", null, InputOption::VALUE_NONE, "Force colors in output."), new InputOption("no-ansi", null, InputOption::VALUE_NONE, "Disable colors in output."), new InputOption("quiet", "q", InputOption::VALUE_NONE, "Shhhhhh."), new InputOption("verbose", "v|vv|vvv", InputOption::VALUE_OPTIONAL, "Increase the verbosity of messages.", "0"), new InputOption("compact", null, InputOption::VALUE_NONE, "Run PsySH with compact output."), new InputOption("interactive", "i|a", InputOption::VALUE_NONE, "Force PsySH to run in interactive mode."), new InputOption("no-interactive", "n", InputOption::VALUE_NONE, "Run PsySH without interactive input. Requires input from stdin."), new InputOption("interaction", null, InputOption::VALUE_NONE, "Force PsySH to run in interactive mode."), new InputOption("no-interaction", null, InputOption::VALUE_NONE, "Run PsySH without interactive input. Requires input from stdin."), new InputOption("raw-output", "r", InputOption::VALUE_NONE, "Print var_export-style return values (for non-interactive input)"), new InputOption("self-update", "u", InputOption::VALUE_NONE, "Update to the latest version"), new InputOption("yolo", null, InputOption::VALUE_NONE, "Run PsySH with minimal input validation. You probably don't want this.")); } public function init() { $this->hasReadline = \function_exists("readline"); $this->hasPcntl = ProcessForker::isSupported(); if ($configFile = $this->getConfigFile()) { $this->loadConfigFile($configFile); } if (!$this->configFile && ($localConfig = $this->getLocalConfigFile())) { $this->loadConfigFile($localConfig); } $this->configPaths->overrideDirs(array("configDir" => $this->configDir, "dataDir" => $this->dataDir, "runtimeDir" => $this->runtimeDir)); } public function getConfigFile() { if (isset($this->configFile)) { return $this->configFile; } $files = $this->configPaths->configFiles(array("config.php", "rc.php")); if (!empty($files)) { if ($this->warnOnMultipleConfigs && \count($files) > 1) { $msg = \sprintf("Multiple configuration files found: %s. Using %s", \implode(", ", $files), $files[0]); \trigger_error($msg, \E_USER_NOTICE); } return $files[0]; } } public function getLocalConfigFile() { $localConfig = \getcwd() . "/.psysh.php"; if (@\is_file($localConfig)) { return $localConfig; } } public function loadConfig(array $options) { foreach (self::$AVAILABLE_OPTIONS as $option) { if (isset($options[$option])) { $method = "set" . \ucfirst($option); $this->{$method}($options[$option]); } } if (isset($options["tabCompletion"])) { $msg = "`tabCompletion` is deprecated; use `useTabCompletion` instead."; @\trigger_error($msg, \E_USER_DEPRECATED); $this->setUseTabCompletion($options["tabCompletion"]); } foreach (array("commands", "matchers", "casters") as $option) { if (isset($options[$option])) { $method = "add" . \ucfirst($option); $this->{$method}($options[$option]); } } if (isset($options["tabCompletionMatchers"])) { $msg = "`tabCompletionMatchers` is deprecated; use `matchers` instead."; @\trigger_error($msg, \E_USER_DEPRECATED); $this->addMatchers($options["tabCompletionMatchers"]); } } public function loadConfigFile(string $file) { if (!\is_file($file)) { throw new \InvalidArgumentException(\sprintf("Invalid configuration file specified, %s does not exist", $file)); } $__psysh_config_file__ = $file; $load = function ($config) use($__psysh_config_file__) { $result = (require $__psysh_config_file__); if ($result !== 1) { return $result; } }; $result = $load($this); if (!empty($result)) { if (\is_array($result)) { $this->loadConfig($result); } else { throw new \InvalidArgumentException("Psy Shell configuration must return an array of options"); } } } public function setDefaultIncludes(array $includes = array()) { $this->defaultIncludes = $includes; } public function getDefaultIncludes() : array { return $this->defaultIncludes ?: array(); } public function setConfigDir(string $dir) { $this->configDir = (string) $dir; $this->configPaths->overrideDirs(array("configDir" => $this->configDir, "dataDir" => $this->dataDir, "runtimeDir" => $this->runtimeDir)); } public function getConfigDir() { return $this->configDir; } public function setDataDir(string $dir) { $this->dataDir = (string) $dir; $this->configPaths->overrideDirs(array("configDir" => $this->configDir, "dataDir" => $this->dataDir, "runtimeDir" => $this->runtimeDir)); } public function getDataDir() { return $this->dataDir; } public function setRuntimeDir(string $dir) { $this->runtimeDir = (string) $dir; $this->configPaths->overrideDirs(array("configDir" => $this->configDir, "dataDir" => $this->dataDir, "runtimeDir" => $this->runtimeDir)); } public function getRuntimeDir() : string { $runtimeDir = $this->configPaths->runtimeDir(); if (!\is_dir($runtimeDir)) { if (!@\mkdir($runtimeDir, 448, true)) { throw new RuntimeException(\sprintf("Unable to create PsySH runtime directory. Make sure PHP is able to write to %s in order to continue.", \dirname($runtimeDir))); } } return $runtimeDir; } public function setHistoryFile(string $file) { $this->historyFile = ConfigPaths::touchFileWithMkdir($file); } public function getHistoryFile() : string { if (isset($this->historyFile)) { return $this->historyFile; } $files = $this->configPaths->configFiles(array("psysh_history", "history")); if (!empty($files)) { if ($this->warnOnMultipleConfigs && \count($files) > 1) { $msg = \sprintf("Multiple history files found: %s. Using %s", \implode(", ", $files), $files[0]); \trigger_error($msg, \E_USER_NOTICE); } $this->setHistoryFile($files[0]); } else { $this->setHistoryFile($this->configPaths->currentConfigDir() . "/psysh_history"); } return $this->historyFile; } public function setHistorySize(int $value) { $this->historySize = (int) $value; } public function getHistorySize() { return $this->historySize; } public function setEraseDuplicates(bool $value) { $this->eraseDuplicates = (bool) $value; } public function getEraseDuplicates() { return $this->eraseDuplicates; } public function getTempFile(string $type, int $pid) : string { return \tempnam($this->getRuntimeDir(), $type . "_" . $pid . "_"); } public function getPipe(string $type, int $pid) : string { return \sprintf("%s/%s_%s", $this->getRuntimeDir(), $type, $pid); } public function hasReadline() : bool { return $this->hasReadline; } public function setUseReadline(bool $useReadline) { $this->useReadline = (bool) $useReadline; } public function useReadline() : bool { return isset($this->useReadline) ? $this->hasReadline && $this->useReadline : $this->hasReadline; } public function setReadline(Readline\Readline $readline) { $this->readline = $readline; } public function getReadline() : Readline\Readline { if (!isset($this->readline)) { $className = $this->getReadlineClass(); $this->readline = new $className($this->getHistoryFile(), $this->getHistorySize(), $this->getEraseDuplicates()); } return $this->readline; } private function getReadlineClass() : string { if ($this->useReadline()) { if (Readline\GNUReadline::isSupported()) { return Readline\GNUReadline::class; } elseif (Readline\Libedit::isSupported()) { return Readline\Libedit::class; } } if (Readline\Userland::isSupported()) { return Readline\Userland::class; } return Readline\Transient::class; } public function setUseBracketedPaste(bool $useBracketedPaste) { $this->useBracketedPaste = (bool) $useBracketedPaste; } public function useBracketedPaste() : bool { $readlineClass = $this->getReadlineClass(); return $this->useBracketedPaste && $readlineClass::supportsBracketedPaste(); } public function hasPcntl() : bool { return $this->hasPcntl; } public function setUsePcntl(bool $usePcntl) { $this->usePcntl = (bool) $usePcntl; } public function usePcntl() : bool { if (!isset($this->usePcntl)) { if (\function_exists("xdebug_is_debugger_active") && \xdebug_is_debugger_active()) { return false; } return $this->hasPcntl; } return $this->hasPcntl && $this->usePcntl; } public function rawOutput() : bool { return $this->rawOutput; } public function setRawOutput(bool $rawOutput) { $this->rawOutput = (bool) $rawOutput; } public function setRequireSemicolons(bool $requireSemicolons) { $this->requireSemicolons = (bool) $requireSemicolons; } public function requireSemicolons() : bool { return $this->requireSemicolons; } public function setStrictTypes($strictTypes) { $this->strictTypes = (bool) $strictTypes; } public function strictTypes() : bool { return $this->strictTypes; } public function setUseUnicode(bool $useUnicode) { $this->useUnicode = (bool) $useUnicode; } public function useUnicode() : bool { if (isset($this->useUnicode)) { return $this->useUnicode; } return true; } public function setErrorLoggingLevel($errorLoggingLevel) { $this->errorLoggingLevel = (\E_ALL | \E_STRICT) & $errorLoggingLevel; } public function errorLoggingLevel() : int { return $this->errorLoggingLevel; } public function setCodeCleaner(CodeCleaner $cleaner) { $this->cleaner = $cleaner; } public function getCodeCleaner() : CodeCleaner { if (!isset($this->cleaner)) { $this->cleaner = new CodeCleaner(null, null, null, $this->yolo(), $this->strictTypes()); } return $this->cleaner; } public function setYolo($yolo) { $this->yolo = (bool) $yolo; } public function yolo() : bool { return $this->yolo; } public function setUseTabCompletion(bool $useTabCompletion) { $this->useTabCompletion = (bool) $useTabCompletion; } public function setTabCompletion(bool $useTabCompletion) { @\trigger_error("`setTabCompletion` is deprecated; call `setUseTabCompletion` instead.", \E_USER_DEPRECATED); $this->setUseTabCompletion($useTabCompletion); } public function useTabCompletion() : bool { return isset($this->useTabCompletion) ? $this->hasReadline && $this->useTabCompletion : $this->hasReadline; } public function getTabCompletion() : bool { @\trigger_error("`getTabCompletion` is deprecated; call `useTabCompletion` instead.", \E_USER_DEPRECATED); return $this->useTabCompletion(); } public function setOutput(ShellOutput $output) { $this->output = $output; $this->pipedOutput = null; if (isset($this->theme)) { $output->setTheme($this->theme); } $this->applyFormatterStyles(); } public function getOutput() : ShellOutput { if (!isset($this->output)) { $this->setOutput(new ShellOutput($this->getOutputVerbosity(), null, null, $this->getPager() ?: null, $this->theme())); $decorated = $this->getOutputDecorated(); if ($decorated !== null) { $this->output->setDecorated($decorated); } } return $this->output; } public function getOutputDecorated() { switch ($this->colorMode()) { case self::COLOR_MODE_FORCED: return true; case self::COLOR_MODE_DISABLED: return false; case self::COLOR_MODE_AUTO: default: return $this->outputIsPiped() ? false : null; } } public function getInputInteractive() : bool { switch ($this->interactiveMode()) { case self::INTERACTIVE_MODE_FORCED: return true; case self::INTERACTIVE_MODE_DISABLED: return false; case self::INTERACTIVE_MODE_AUTO: default: return !$this->inputIsPiped(); } } public function setPager($pager) { if ($pager === null || $pager === false || $pager === "cat") { $pager = false; } if ($pager !== false && !\is_string($pager) && !$pager instanceof OutputPager) { throw new \InvalidArgumentException("Unexpected pager instance"); } $this->pager = $pager; } public function getPager() { if (!isset($this->pager) && $this->usePcntl()) { if (\getenv("TERM") === "dumb") { return false; } if ($pager = \ini_get("cli.pager")) { $this->pager = $pager; } elseif ($less = $this->configPaths->which("less")) { $link = @\readlink($less); if ($link !== false && \strpos($link, "busybox") !== false) { return false; } $this->pager = $less . " -R -F -X"; } } return $this->pager; } public function setAutoCompleter(AutoCompleter $autoCompleter) { $this->autoCompleter = $autoCompleter; } public function getAutoCompleter() : AutoCompleter { if (!isset($this->autoCompleter)) { $this->autoCompleter = new AutoCompleter(); } return $this->autoCompleter; } public function getTabCompletionMatchers() : array { @\trigger_error("`getTabCompletionMatchers` is no longer used.", \E_USER_DEPRECATED); return array(); } public function addMatchers(array $matchers) { $this->newMatchers = \array_merge($this->newMatchers, $matchers); if (isset($this->shell)) { $this->doAddMatchers(); } } private function doAddMatchers() { if (!empty($this->newMatchers)) { $this->shell->addMatchers($this->newMatchers); $this->newMatchers = array(); } } public function addTabCompletionMatchers(array $matchers) { @\trigger_error("`addTabCompletionMatchers` is deprecated; call `addMatchers` instead.", \E_USER_DEPRECATED); $this->addMatchers($matchers); } public function addCommands(array $commands) { $this->newCommands = \array_merge($this->newCommands, $commands); if (isset($this->shell)) { $this->doAddCommands(); } } private function doAddCommands() { if (!empty($this->newCommands)) { $this->shell->addCommands($this->newCommands); $this->newCommands = array(); } } public function setShell(Shell $shell) { $this->shell = $shell; $this->doAddCommands(); $this->doAddMatchers(); } public function setManualDbFile(string $filename) { $this->manualDbFile = (string) $filename; } public function getManualDbFile() { if (isset($this->manualDbFile)) { return $this->manualDbFile; } $files = $this->configPaths->dataFiles(array("php_manual.sqlite")); if (!empty($files)) { if ($this->warnOnMultipleConfigs && \count($files) > 1) { $msg = \sprintf("Multiple manual database files found: %s. Using %s", \implode(", ", $files), $files[0]); \trigger_error($msg, \E_USER_NOTICE); } return $this->manualDbFile = $files[0]; } } public function getManualDb() { if (!isset($this->manualDb)) { $dbFile = $this->getManualDbFile(); if ($dbFile !== null && \is_file($dbFile)) { try { $this->manualDb = new \PDO("sqlite:" . $dbFile); } catch (\PDOException $e) { if ($e->getMessage() === "could not find driver") { throw new RuntimeException("SQLite PDO driver not found", 0, $e); } else { throw $e; } } } } return $this->manualDb; } public function addCasters(array $casters) { $this->getPresenter()->addCasters($casters); } public function getPresenter() : Presenter { if (!isset($this->presenter)) { $this->presenter = new Presenter($this->getOutput()->getFormatter(), $this->forceArrayIndexes()); } return $this->presenter; } public function setWarnOnMultipleConfigs(bool $warnOnMultipleConfigs) { $this->warnOnMultipleConfigs = (bool) $warnOnMultipleConfigs; } public function warnOnMultipleConfigs() : bool { return $this->warnOnMultipleConfigs; } public function setColorMode(string $colorMode) { $validColorModes = array(self::COLOR_MODE_AUTO, self::COLOR_MODE_FORCED, self::COLOR_MODE_DISABLED); if (!\in_array($colorMode, $validColorModes)) { throw new \InvalidArgumentException("Invalid color mode: " . $colorMode); } $this->colorMode = $colorMode; } public function colorMode() : string { return $this->colorMode; } public function setInteractiveMode(string $interactiveMode) { $validInteractiveModes = array(self::INTERACTIVE_MODE_AUTO, self::INTERACTIVE_MODE_FORCED, self::INTERACTIVE_MODE_DISABLED); if (!\in_array($interactiveMode, $validInteractiveModes)) { throw new \InvalidArgumentException("Invalid interactive mode: " . $interactiveMode); } $this->interactiveMode = $interactiveMode; } public function interactiveMode() : string { return $this->interactiveMode; } public function setChecker(Checker $checker) { $this->checker = $checker; } public function getChecker() : Checker { if (!isset($this->checker)) { $interval = $this->getUpdateCheck(); switch ($interval) { case Checker::ALWAYS: $this->checker = new GitHubChecker(); break; case Checker::DAILY: case Checker::WEEKLY: case Checker::MONTHLY: $checkFile = $this->getUpdateCheckCacheFile(); if ($checkFile === false) { $this->checker = new NoopChecker(); } else { $this->checker = new IntervalChecker($checkFile, $interval); } break; case Checker::NEVER: $this->checker = new NoopChecker(); break; } } return $this->checker; } public function getUpdateCheck() : string { return isset($this->updateCheck) ? $this->updateCheck : Checker::WEEKLY; } public function setUpdateCheck(string $interval) { $validIntervals = array(Checker::ALWAYS, Checker::DAILY, Checker::WEEKLY, Checker::MONTHLY, Checker::NEVER); if (!\in_array($interval, $validIntervals)) { throw new \InvalidArgumentException("Invalid update check interval: " . $interval); } $this->updateCheck = $interval; } public function getUpdateCheckCacheFile() { return ConfigPaths::touchFileWithMkdir($this->configPaths->currentConfigDir() . "/update_check.json"); } public function setStartupMessage(string $message) { $this->startupMessage = $message; } public function getStartupMessage() { return $this->startupMessage; } public function setPrompt(string $prompt) { $this->prompt = $prompt; if (isset($this->theme)) { $this->theme->setPrompt($prompt); } } public function getPrompt() { return $this->prompt; } public function forceArrayIndexes() : bool { return $this->forceArrayIndexes; } public function setForceArrayIndexes(bool $forceArrayIndexes) { $this->forceArrayIndexes = $forceArrayIndexes; } public function setTheme($theme) { if (!$theme instanceof Theme) { $theme = new Theme($theme); } $this->theme = $theme; if (isset($this->prompt)) { $this->theme->setPrompt($this->prompt); } if (isset($this->output)) { $this->output->setTheme($theme); $this->applyFormatterStyles(); } } public function theme() : Theme { if (!isset($this->theme)) { $this->theme = $this->prompt ? new Theme("classic") : new Theme(); } if (isset($this->prompt)) { $this->theme->setPrompt($this->prompt); } return $this->theme; } public function setFormatterStyles(array $formatterStyles) { foreach ($formatterStyles as $name => $style) { $this->formatterStyles[$name] = new OutputFormatterStyle(...$style); } if (isset($this->output)) { $this->applyFormatterStyles(); } } private function applyFormatterStyles() { $formatter = $this->output->getFormatter(); foreach ($this->formatterStyles as $name => $style) { $formatter->setStyle($name, $style); } $errorFormatter = $this->output->getErrorOutput()->getFormatter(); foreach (Theme::ERROR_STYLES as $name) { if (isset($this->formatterStyles[$name])) { $errorFormatter->setStyle($name, $this->formatterStyles[$name]); } } } public function verbosity() : string { return $this->verbosity; } public function setVerbosity(string $verbosity) { $validVerbosityLevels = array(self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE, self::VERBOSITY_VERY_VERBOSE, self::VERBOSITY_DEBUG); if (!\in_array($verbosity, $validVerbosityLevels)) { throw new \InvalidArgumentException("Invalid verbosity level: " . $verbosity); } $this->verbosity = $verbosity; if (isset($this->output)) { $this->output->setVerbosity($this->getOutputVerbosity()); } } public function getOutputVerbosity() : int { switch ($this->verbosity()) { case self::VERBOSITY_QUIET: return OutputInterface::VERBOSITY_QUIET; case self::VERBOSITY_VERBOSE: return OutputInterface::VERBOSITY_VERBOSE; case self::VERBOSITY_VERY_VERBOSE: return OutputInterface::VERBOSITY_VERY_VERBOSE; case self::VERBOSITY_DEBUG: return OutputInterface::VERBOSITY_DEBUG; case self::VERBOSITY_NORMAL: default: return OutputInterface::VERBOSITY_NORMAL; } } public function inputIsPiped() : bool { if ($this->pipedInput === null) { $this->pipedInput = \defined("STDIN") && self::looksLikeAPipe(\STDIN); } return $this->pipedInput; } public function outputIsPiped() : bool { if ($this->pipedOutput === null) { $this->pipedOutput = self::looksLikeAPipe($this->getOutput()->getStream()); } return $this->pipedOutput; } private static function looksLikeAPipe($stream) : bool { if (\function_exists("posix_isatty")) { return !\posix_isatty($stream); } $stat = \fstat($stream); $mode = $stat["mode"] & 61440; return $mode === 4096 || $mode === 16384 || $mode === 32768 || $mode === 40960; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Psy; use Psy\Exception\DeprecatedException; use Psy\Exception\RuntimeException; use Psy\ExecutionLoop\ProcessForker; use Psy\Output\OutputPager; use Psy\Output\ShellOutput; use Psy\Output\Theme; use Psy\TabCompletion\AutoCompleter; use Psy\VarDumper\Presenter; use Psy\VersionUpdater\Checker; use Psy\VersionUpdater\GitHubChecker; use Psy\VersionUpdater\IntervalChecker; use Psy\VersionUpdater\NoopChecker; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Configuration { const COLOR_MODE_AUTO = "\141\165\x74\157"; const COLOR_MODE_FORCED = "\146\x6f\162\143\145\144"; const COLOR_MODE_DISABLED = "\144\151\163\141\x62\154\x65\144"; const INTERACTIVE_MODE_AUTO = "\x61\x75\x74\157"; const INTERACTIVE_MODE_FORCED = "\146\x6f\162\143\145\144"; const INTERACTIVE_MODE_DISABLED = "\144\151\x73\141\x62\x6c\x65\144"; const VERBOSITY_QUIET = "\x71\x75\151\x65\164"; const VERBOSITY_NORMAL = "\156\x6f\162\155\141\154"; const VERBOSITY_VERBOSE = "\x76\x65\162\142\157\163\x65"; const VERBOSITY_VERY_VERBOSE = "\x76\145\162\x79\137\x76\145\x72\142\x6f\163\x65"; const VERBOSITY_DEBUG = "\144\145\x62\x75\147"; private static $AVAILABLE_OPTIONS = array("\143\x6f\144\145\103\x6c\145\x61\x6e\x65\x72", "\143\157\x6c\157\162\x4d\157\144\145", "\x63\x6f\156\x66\x69\147\104\151\162", "\x64\141\x74\x61\x44\151\x72", "\x64\145\146\141\165\154\164\111\x6e\x63\x6c\x75\144\145\x73", "\145\x72\141\163\145\x44\165\x70\154\151\143\141\x74\x65\x73", "\145\x72\x72\157\162\x4c\157\147\147\x69\x6e\x67\114\145\x76\145\154", "\146\x6f\162\143\x65\101\x72\x72\141\171\111\156\x64\145\170\145\x73", "\x66\157\162\155\x61\164\x74\145\162\123\x74\171\154\x65\163", "\x68\151\163\164\157\x72\171\x46\x69\x6c\145", "\x68\x69\163\164\157\162\171\123\x69\x7a\x65", "\x69\156\164\145\x72\141\x63\164\x69\x76\x65\115\157\x64\145", "\155\141\156\165\141\154\104\142\106\x69\154\x65", "\160\141\x67\145\x72", "\160\162\157\x6d\160\164", "\x72\x61\x77\x4f\x75\164\160\x75\x74", "\162\x65\x71\x75\x69\x72\145\x53\x65\x6d\x69\x63\x6f\154\157\156\x73", "\x72\165\156\164\x69\x6d\145\104\x69\162", "\x73\x74\141\162\x74\x75\160\115\x65\163\x73\141\x67\x65", "\x73\x74\x72\151\x63\x74\124\171\160\x65\x73", "\x74\150\145\155\145", "\x75\160\144\141\164\145\103\150\x65\x63\x6b", "\165\163\145\x42\162\x61\x63\153\145\164\145\x64\120\x61\x73\x74\145", "\165\x73\145\x50\143\156\x74\154", "\x75\163\x65\x52\x65\x61\144\x6c\x69\x6e\x65", "\x75\163\145\x54\141\142\103\157\x6d\160\x6c\145\x74\x69\157\156", "\x75\x73\x65\125\x6e\x69\x63\x6f\x64\x65", "\166\145\162\x62\x6f\163\151\164\x79", "\x77\x61\162\156\117\156\x4d\165\154\164\x69\x70\x6c\x65\103\x6f\x6e\x66\x69\147\x73", "\171\x6f\154\157"); private $defaultIncludes; private $configDir; private $dataDir; private $runtimeDir; private $configFile; private $historyFile; private $historySize; private $eraseDuplicates; private $manualDbFile; private $hasReadline; private $useReadline; private $useBracketedPaste; private $hasPcntl; private $usePcntl; private $newCommands = array(); private $pipedInput; private $pipedOutput; private $rawOutput = false; private $requireSemicolons = false; private $strictTypes = false; private $useUnicode; private $useTabCompletion; private $newMatchers = array(); private $errorLoggingLevel = \E_ALL; private $warnOnMultipleConfigs = false; private $colorMode = self::COLOR_MODE_AUTO; private $interactiveMode = self::INTERACTIVE_MODE_AUTO; private $updateCheck; private $startupMessage; private $forceArrayIndexes = false; private $formatterStyles = array(); private $verbosity = self::VERBOSITY_NORMAL; private $yolo = false; private $theme; private $readline; private $output; private $shell; private $cleaner; private $pager; private $manualDb; private $presenter; private $autoCompleter; private $checker; private $prompt; private $configPaths; public function __construct(array $config = array()) { $this->configPaths = new ConfigPaths(); if (isset($config["\143\157\x6e\146\151\147\106\x69\154\x65"])) { $this->configFile = $config["\143\157\156\x66\151\147\x46\x69\154\x65"]; } elseif (isset($_SERVER["\x50\123\x59\123\x48\x5f\x43\117\116\106\x49\x47"]) && $_SERVER["\x50\123\131\123\110\137\x43\117\116\x46\111\107"]) { $this->configFile = $_SERVER["\120\x53\x59\x53\x48\137\103\x4f\116\106\111\x47"]; } elseif (\PHP_SAPI === "\143\154\151\55\x73\x65\162\166\x65\x72" && ($configFile = \getenv("\x50\123\131\x53\x48\x5f\x43\x4f\116\x46\x49\107"))) { $this->configFile = $configFile; } if (isset($config["\142\x61\163\x65\x44\x69\162"])) { $msg = "\x54\150\x65\x20\47\142\x61\163\x65\x44\x69\162\47\40\143\157\x6e\x66\151\147\x75\x72\x61\x74\151\157\156\x20\157\160\x74\x69\x6f\x6e\x20\151\163\x20\x64\x65\160\x72\145\x63\141\164\145\x64\x3b\40" . "\x70\x6c\145\141\163\x65\40\x73\160\x65\143\151\146\171\x20\x27\143\x6f\x6e\x66\x69\x67\x44\151\x72\47\40\x61\156\144\x20\x27\x64\141\164\x61\x44\x69\162\47\x20\x6f\x70\x74\x69\157\156\163\40\x69\156\163\164\x65\141\x64"; throw new DeprecatedException($msg); } unset($config["\143\157\x6e\146\151\x67\x46\x69\x6c\x65"], $config["\142\141\x73\145\x44\x69\x72"]); $this->loadConfig($config); $this->init(); } public static function fromInput(InputInterface $input) : self { $config = new self(array("\143\157\x6e\x66\x69\x67\106\x69\154\145" => self::getConfigFileFromInput($input))); if (self::getOptionFromInput($input, array("\143\157\154\157\162", "\141\156\x73\151"))) { $config->setColorMode(self::COLOR_MODE_FORCED); } elseif (self::getOptionFromInput($input, array("\156\x6f\55\x63\x6f\154\157\x72", "\x6e\157\x2d\141\x6e\163\151"))) { $config->setColorMode(self::COLOR_MODE_DISABLED); } if ($verbosity = self::getVerbosityFromInput($input)) { $config->setVerbosity($verbosity); } if (self::getOptionFromInput($input, array("\151\156\164\145\x72\x61\143\x74\151\166\145", "\151\156\164\x65\x72\141\143\164\x69\157\156"), array("\x2d\141", "\55\x69"))) { $config->setInteractiveMode(self::INTERACTIVE_MODE_FORCED); } elseif (self::getOptionFromInput($input, array("\156\157\55\x69\x6e\164\145\162\x61\143\164\x69\166\x65", "\x6e\157\55\151\156\x74\x65\x72\x61\x63\x74\151\x6f\156"), array("\55\x6e"))) { $config->setInteractiveMode(self::INTERACTIVE_MODE_DISABLED); } if (self::getOptionFromInput($input, array("\143\157\155\160\x61\143\164"))) { $config->setTheme("\x63\x6f\x6d\160\141\143\x74"); } if (!$config->getInputInteractive()) { if (self::getOptionFromInput($input, array("\162\141\167\x2d\x6f\x75\x74\x70\165\164"), array("\55\162"))) { $config->setRawOutput(true); } } if (self::getOptionFromInput($input, array("\171\x6f\x6c\157"))) { $config->setYolo(true); } return $config; } private static function getConfigFileFromInput(InputInterface $input) { if ($input->hasOption("\143\157\156\146\x69\147")) { return $input->getOption("\x63\157\156\146\151\x67"); } return $input->getParameterOption("\x2d\x2d\143\157\x6e\x66\151\147", null, true) ?: $input->getParameterOption("\55\143", null, true); } private static function getOptionFromInput(InputInterface $input, array $names, array $otherParams = array()) : bool { foreach ($names as $name) { if ($input->hasOption($name) && $input->getOption($name)) { return true; } } foreach ($names as $name) { $otherParams[] = "\x2d\55" . $name; } foreach ($otherParams as $name) { if ($input->hasParameterOption($name, true)) { return true; } } return false; } private static function getVerbosityFromInput(InputInterface $input) { if (self::getOptionFromInput($input, array("\x71\x75\x69\x65\x74"), array("\x2d\161"))) { return self::VERBOSITY_QUIET; } if ($input->hasOption("\166\145\x72\142\157\x73\145") && $input->getOption("\x76\145\162\x62\157\163\145") !== true) { switch ($input->getOption("\166\145\x72\142\x6f\163\x65")) { case "\x2d\x31": return self::VERBOSITY_QUIET; case "\x30": return self::VERBOSITY_NORMAL; case "\61": case null: return self::VERBOSITY_VERBOSE; case "\62": case "\x76": return self::VERBOSITY_VERY_VERBOSE; case "\63": case "\x76\x76": return self::VERBOSITY_DEBUG; default: return; } } if ($input->hasParameterOption("\55\x2d\166\145\x72\142\157\163\x65\x3d\55\61", true) || $input->getParameterOption("\55\55\x76\145\x72\142\x6f\163\145", false, true) === "\x2d\61") { return self::VERBOSITY_QUIET; } if ($input->hasParameterOption("\55\x2d\x76\x65\162\x62\157\x73\x65\x3d\60", true) || $input->getParameterOption("\55\55\166\145\x72\x62\157\x73\145", false, true) === "\60") { return self::VERBOSITY_NORMAL; } if ($input->hasParameterOption("\x2d\166\166\x76", true) || $input->hasParameterOption("\55\x2d\166\145\162\142\x6f\x73\x65\75\63", true) || $input->getParameterOption("\55\55\166\x65\x72\142\x6f\x73\145", false, true) === "\63") { return self::VERBOSITY_DEBUG; } if ($input->hasParameterOption("\x2d\x76\x76", true) || $input->hasParameterOption("\x2d\x2d\166\x65\x72\142\x6f\x73\x65\75\62", true) || $input->getParameterOption("\x2d\x2d\166\145\x72\x62\157\x73\145", false, true) === "\62") { return self::VERBOSITY_VERY_VERBOSE; } if ($input->hasParameterOption("\55\x76", true) || $input->hasParameterOption("\x2d\55\166\x65\162\x62\157\x73\x65\x3d\61", true) || $input->hasParameterOption("\x2d\x2d\166\x65\x72\x62\157\x73\x65", true)) { return self::VERBOSITY_VERBOSE; } } public static function getInputOptions() : array { return array(new InputOption("\x63\x6f\x6e\x66\151\x67", "\143", InputOption::VALUE_REQUIRED, "\125\163\145\40\x61\156\40\141\x6c\164\x65\162\156\x61\164\x65\x20\x50\x73\171\x53\110\40\x63\157\x6e\x66\x69\147\x20\146\151\x6c\x65\40\x6c\157\x63\x61\164\151\157\x6e\56"), new InputOption("\x63\167\144", null, InputOption::VALUE_REQUIRED, "\x55\x73\x65\x20\x61\x6e\40\x61\x6c\x74\145\x72\156\141\x74\x65\x20\x77\157\x72\x6b\x69\x6e\x67\40\x64\151\162\145\143\x74\x6f\162\171\56"), new InputOption("\x63\x6f\x6c\157\162", null, InputOption::VALUE_NONE, "\x46\157\x72\x63\x65\x20\143\x6f\154\x6f\x72\163\40\151\x6e\40\157\165\x74\160\165\164\x2e"), new InputOption("\156\x6f\55\143\157\x6c\157\162", null, InputOption::VALUE_NONE, "\x44\151\163\x61\x62\154\x65\x20\143\x6f\154\157\162\163\40\x69\156\40\157\165\164\x70\x75\164\56"), new InputOption("\x61\x6e\163\151", null, InputOption::VALUE_NONE, "\106\x6f\x72\143\x65\40\x63\157\x6c\157\162\x73\40\151\x6e\40\x6f\165\164\160\x75\x74\x2e"), new InputOption("\156\157\x2d\141\156\x73\151", null, InputOption::VALUE_NONE, "\104\x69\163\x61\x62\x6c\145\x20\x63\157\x6c\x6f\x72\163\40\151\x6e\x20\x6f\165\x74\160\165\164\56"), new InputOption("\x71\x75\x69\145\x74", "\x71", InputOption::VALUE_NONE, "\123\150\x68\150\150\x68\150\x2e"), new InputOption("\x76\x65\x72\x62\157\163\x65", "\166\174\166\166\x7c\166\166\166", InputOption::VALUE_OPTIONAL, "\111\x6e\143\x72\145\141\x73\x65\40\x74\x68\x65\40\166\145\162\142\x6f\x73\151\x74\x79\x20\x6f\x66\40\155\x65\x73\x73\x61\x67\145\163\x2e", "\60"), new InputOption("\x63\x6f\x6d\160\x61\143\x74", null, InputOption::VALUE_NONE, "\122\165\156\x20\x50\x73\171\123\110\x20\x77\151\x74\x68\40\143\x6f\x6d\160\141\x63\164\40\157\165\x74\x70\165\164\x2e"), new InputOption("\151\x6e\164\x65\x72\x61\x63\164\x69\166\145", "\x69\174\141", InputOption::VALUE_NONE, "\106\157\162\x63\x65\40\x50\163\171\x53\x48\40\164\157\x20\162\x75\x6e\40\151\x6e\x20\x69\156\x74\145\x72\x61\143\x74\151\166\145\x20\155\x6f\x64\145\56"), new InputOption("\x6e\x6f\55\151\x6e\164\145\x72\x61\x63\x74\151\x76\x65", "\156", InputOption::VALUE_NONE, "\122\x75\156\40\x50\x73\x79\x53\x48\40\x77\151\x74\150\157\165\x74\40\x69\x6e\x74\145\162\x61\143\164\x69\x76\x65\40\x69\x6e\160\x75\164\56\40\122\x65\x71\165\x69\162\145\163\40\x69\x6e\160\165\164\x20\x66\x72\x6f\x6d\40\x73\x74\x64\151\x6e\56"), new InputOption("\151\156\x74\x65\x72\x61\x63\164\x69\157\156", null, InputOption::VALUE_NONE, "\106\157\162\x63\145\x20\x50\163\x79\x53\x48\40\x74\157\40\x72\x75\156\40\x69\156\x20\x69\156\164\x65\162\x61\x63\164\x69\166\145\x20\155\157\x64\x65\56"), new InputOption("\x6e\157\x2d\x69\156\164\x65\162\x61\143\164\x69\x6f\x6e", null, InputOption::VALUE_NONE, "\x52\165\x6e\x20\x50\163\x79\x53\x48\x20\x77\x69\x74\x68\x6f\x75\x74\40\151\156\164\145\x72\141\x63\164\151\166\145\x20\151\156\160\x75\164\x2e\40\x52\x65\161\165\151\x72\x65\163\40\151\x6e\160\165\164\40\x66\162\x6f\x6d\40\x73\x74\144\151\156\56"), new InputOption("\162\141\167\x2d\157\165\x74\160\x75\164", "\162", InputOption::VALUE_NONE, "\120\x72\x69\156\x74\40\166\141\162\x5f\x65\x78\160\157\162\x74\x2d\x73\x74\x79\x6c\x65\x20\162\145\164\165\x72\156\40\x76\x61\154\165\145\x73\40\x28\146\x6f\162\40\156\x6f\x6e\55\x69\x6e\164\145\162\x61\x63\164\151\166\x65\40\151\x6e\160\165\164\51"), new InputOption("\x73\x65\154\146\55\x75\x70\144\x61\164\x65", "\x75", InputOption::VALUE_NONE, "\125\x70\x64\141\x74\145\x20\164\157\40\164\x68\145\40\x6c\141\x74\145\x73\164\40\166\x65\162\x73\x69\x6f\156"), new InputOption("\171\x6f\x6c\x6f", null, InputOption::VALUE_NONE, "\122\165\156\x20\x50\x73\171\x53\x48\x20\167\x69\x74\150\x20\x6d\151\156\x69\155\x61\x6c\40\151\156\x70\x75\164\40\x76\141\x6c\x69\x64\x61\x74\151\x6f\156\56\x20\131\157\165\40\x70\x72\x6f\x62\x61\x62\154\171\x20\144\157\156\47\x74\x20\167\141\x6e\x74\x20\x74\x68\151\163\56")); } public function init() { $this->hasReadline = \function_exists("\162\145\x61\x64\x6c\151\156\145"); $this->hasPcntl = ProcessForker::isSupported(); if ($configFile = $this->getConfigFile()) { $this->loadConfigFile($configFile); } if (!$this->configFile && ($localConfig = $this->getLocalConfigFile())) { $this->loadConfigFile($localConfig); } $this->configPaths->overrideDirs(array("\x63\157\x6e\146\x69\x67\x44\151\162" => $this->configDir, "\x64\x61\x74\x61\104\x69\162" => $this->dataDir, "\x72\165\156\x74\x69\x6d\145\104\151\162" => $this->runtimeDir)); } public function getConfigFile() { if (isset($this->configFile)) { return $this->configFile; } $files = $this->configPaths->configFiles(array("\x63\x6f\x6e\x66\151\x67\56\x70\150\x70", "\162\143\56\x70\x68\160")); if (!empty($files)) { if ($this->warnOnMultipleConfigs && \count($files) > 1) { $msg = \sprintf("\115\165\154\164\151\x70\x6c\145\40\143\x6f\156\x66\151\147\x75\162\x61\x74\x69\x6f\156\40\146\151\x6c\x65\163\x20\146\157\165\x6e\144\x3a\40\x25\x73\x2e\x20\x55\163\x69\156\x67\40\x25\x73", \implode("\54\40", $files), $files[0]); \trigger_error($msg, \E_USER_NOTICE); } return $files[0]; } } public function getLocalConfigFile() { $localConfig = \getcwd() . "\57\x2e\x70\x73\x79\163\150\x2e\160\150\160"; if (@\is_file($localConfig)) { return $localConfig; } } public function loadConfig(array $options) { foreach (self::$AVAILABLE_OPTIONS as $option) { if (isset($options[$option])) { $method = "\x73\145\x74" . \ucfirst($option); $this->{$method}($options[$option]); } } if (isset($options["\x74\141\x62\103\157\155\160\x6c\145\164\x69\x6f\156"])) { $msg = "\140\164\141\x62\x43\157\x6d\160\x6c\145\x74\151\x6f\x6e\140\x20\x69\x73\x20\x64\145\160\x72\x65\143\141\164\x65\144\73\40\x75\163\145\40\140\165\163\x65\124\141\x62\x43\x6f\155\160\x6c\x65\164\x69\157\156\140\x20\x69\156\x73\164\x65\141\144\56"; @\trigger_error($msg, \E_USER_DEPRECATED); $this->setUseTabCompletion($options["\164\x61\142\x43\x6f\x6d\x70\x6c\x65\x74\x69\x6f\x6e"]); } foreach (array("\143\x6f\x6d\x6d\x61\x6e\x64\x73", "\155\141\x74\143\x68\145\x72\163", "\143\x61\163\164\145\162\163") as $option) { if (isset($options[$option])) { $method = "\141\144\144" . \ucfirst($option); $this->{$method}($options[$option]); } } if (isset($options["\x74\141\142\103\157\x6d\x70\154\x65\164\x69\157\156\x4d\141\x74\143\150\145\162\163"])) { $msg = "\x60\x74\x61\142\x43\x6f\155\160\x6c\145\164\151\x6f\156\115\141\x74\143\150\x65\x72\163\140\40\151\163\x20\x64\x65\x70\162\145\143\x61\164\x65\x64\73\x20\165\163\x65\x20\x60\155\x61\x74\143\150\145\x72\163\x60\40\151\x6e\x73\x74\145\x61\x64\56"; @\trigger_error($msg, \E_USER_DEPRECATED); $this->addMatchers($options["\x74\141\x62\103\157\x6d\160\154\145\x74\x69\157\x6e\115\141\164\143\x68\x65\162\163"]); } } public function loadConfigFile(string $file) { if (!\is_file($file)) { throw new \InvalidArgumentException(\sprintf("\111\x6e\166\141\154\151\144\x20\143\x6f\x6e\146\x69\x67\165\162\x61\164\151\157\156\x20\x66\x69\154\x65\x20\x73\160\x65\143\151\146\x69\x65\144\54\x20\x25\163\x20\x64\157\145\x73\40\156\x6f\164\x20\145\170\151\x73\x74", $file)); } $__psysh_config_file__ = $file; $load = function ($config) use($__psysh_config_file__) { $result = (require $__psysh_config_file__); if ($result !== 1) { return $result; } }; $result = $load($this); if (!empty($result)) { if (\is_array($result)) { $this->loadConfig($result); } else { throw new \InvalidArgumentException("\x50\x73\x79\40\x53\x68\145\154\x6c\40\x63\157\x6e\x66\x69\147\165\x72\141\164\151\157\x6e\x20\155\x75\163\x74\40\x72\x65\164\165\162\x6e\x20\141\156\40\x61\x72\162\141\x79\40\x6f\x66\40\x6f\x70\164\x69\x6f\x6e\x73"); } } } public function setDefaultIncludes(array $includes = array()) { $this->defaultIncludes = $includes; } public function getDefaultIncludes() : array { return $this->defaultIncludes ?: array(); } public function setConfigDir(string $dir) { $this->configDir = (string) $dir; $this->configPaths->overrideDirs(array("\143\157\156\146\x69\147\104\x69\x72" => $this->configDir, "\x64\141\x74\141\104\x69\162" => $this->dataDir, "\162\x75\156\x74\x69\155\x65\104\151\162" => $this->runtimeDir)); } public function getConfigDir() { return $this->configDir; } public function setDataDir(string $dir) { $this->dataDir = (string) $dir; $this->configPaths->overrideDirs(array("\x63\x6f\156\x66\151\x67\104\x69\162" => $this->configDir, "\x64\x61\x74\141\x44\x69\162" => $this->dataDir, "\x72\165\x6e\x74\151\x6d\145\104\x69\162" => $this->runtimeDir)); } public function getDataDir() { return $this->dataDir; } public function setRuntimeDir(string $dir) { $this->runtimeDir = (string) $dir; $this->configPaths->overrideDirs(array("\143\x6f\x6e\146\151\147\x44\151\162" => $this->configDir, "\144\141\164\x61\x44\x69\162" => $this->dataDir, "\162\x75\156\164\x69\x6d\145\104\x69\162" => $this->runtimeDir)); } public function getRuntimeDir() : string { $runtimeDir = $this->configPaths->runtimeDir(); if (!\is_dir($runtimeDir)) { if (!@\mkdir($runtimeDir, 448, true)) { throw new RuntimeException(\sprintf("\x55\x6e\x61\x62\154\x65\x20\x74\157\40\143\x72\x65\141\x74\x65\40\x50\x73\x79\123\110\x20\162\165\156\x74\151\155\x65\40\144\x69\162\x65\x63\164\x6f\x72\171\56\x20\115\x61\x6b\x65\x20\x73\165\x72\145\x20\120\110\x50\x20\151\163\x20\141\142\154\x65\x20\164\157\x20\x77\x72\151\x74\x65\40\164\157\x20\45\163\40\x69\x6e\40\157\162\x64\x65\x72\40\164\157\x20\x63\x6f\156\164\151\x6e\165\x65\x2e", \dirname($runtimeDir))); } } return $runtimeDir; } public function setHistoryFile(string $file) { $this->historyFile = ConfigPaths::touchFileWithMkdir($file); } public function getHistoryFile() : string { if (isset($this->historyFile)) { return $this->historyFile; } $files = $this->configPaths->configFiles(array("\160\163\171\163\x68\x5f\x68\151\x73\164\157\162\x79", "\150\151\x73\164\157\x72\x79")); if (!empty($files)) { if ($this->warnOnMultipleConfigs && \count($files) > 1) { $msg = \sprintf("\115\165\154\164\151\160\154\145\x20\x68\x69\163\164\157\162\x79\x20\x66\x69\x6c\145\163\x20\146\157\165\x6e\144\72\40\45\x73\56\x20\125\163\x69\x6e\x67\x20\x25\x73", \implode("\x2c\x20", $files), $files[0]); \trigger_error($msg, \E_USER_NOTICE); } $this->setHistoryFile($files[0]); } else { $this->setHistoryFile($this->configPaths->currentConfigDir() . "\57\x70\x73\171\163\x68\137\150\151\x73\x74\157\162\171"); } return $this->historyFile; } public function setHistorySize(int $value) { $this->historySize = (int) $value; } public function getHistorySize() { return $this->historySize; } public function setEraseDuplicates(bool $value) { $this->eraseDuplicates = (bool) $value; } public function getEraseDuplicates() { return $this->eraseDuplicates; } public function getTempFile(string $type, int $pid) : string { return \tempnam($this->getRuntimeDir(), $type . "\137" . $pid . "\137"); } public function getPipe(string $type, int $pid) : string { return \sprintf("\x25\x73\x2f\45\x73\137\x25\163", $this->getRuntimeDir(), $type, $pid); } public function hasReadline() : bool { return $this->hasReadline; } public function setUseReadline(bool $useReadline) { $this->useReadline = (bool) $useReadline; } public function useReadline() : bool { return isset($this->useReadline) ? $this->hasReadline && $this->useReadline : $this->hasReadline; } public function setReadline(Readline\Readline $readline) { $this->readline = $readline; } public function getReadline() : Readline\Readline { if (!isset($this->readline)) { $className = $this->getReadlineClass(); $this->readline = new $className($this->getHistoryFile(), $this->getHistorySize(), $this->getEraseDuplicates()); } return $this->readline; } private function getReadlineClass() : string { if ($this->useReadline()) { if (Readline\GNUReadline::isSupported()) { return Readline\GNUReadline::class; } elseif (Readline\Libedit::isSupported()) { return Readline\Libedit::class; } } if (Readline\Userland::isSupported()) { return Readline\Userland::class; } return Readline\Transient::class; } public function setUseBracketedPaste(bool $useBracketedPaste) { $this->useBracketedPaste = (bool) $useBracketedPaste; } public function useBracketedPaste() : bool { $readlineClass = $this->getReadlineClass(); return $this->useBracketedPaste && $readlineClass::supportsBracketedPaste(); } public function hasPcntl() : bool { return $this->hasPcntl; } public function setUsePcntl(bool $usePcntl) { $this->usePcntl = (bool) $usePcntl; } public function usePcntl() : bool { if (!isset($this->usePcntl)) { if (\function_exists("\x78\144\145\x62\x75\x67\x5f\x69\163\x5f\144\x65\142\165\x67\x67\145\x72\x5f\x61\x63\164\x69\x76\145") && \xdebug_is_debugger_active()) { return false; } return $this->hasPcntl; } return $this->hasPcntl && $this->usePcntl; } public function rawOutput() : bool { return $this->rawOutput; } public function setRawOutput(bool $rawOutput) { $this->rawOutput = (bool) $rawOutput; } public function setRequireSemicolons(bool $requireSemicolons) { $this->requireSemicolons = (bool) $requireSemicolons; } public function requireSemicolons() : bool { return $this->requireSemicolons; } public function setStrictTypes($strictTypes) { $this->strictTypes = (bool) $strictTypes; } public function strictTypes() : bool { return $this->strictTypes; } public function setUseUnicode(bool $useUnicode) { $this->useUnicode = (bool) $useUnicode; } public function useUnicode() : bool { if (isset($this->useUnicode)) { return $this->useUnicode; } return true; } public function setErrorLoggingLevel($errorLoggingLevel) { $this->errorLoggingLevel = (\E_ALL | \E_STRICT) & $errorLoggingLevel; } public function errorLoggingLevel() : int { return $this->errorLoggingLevel; } public function setCodeCleaner(CodeCleaner $cleaner) { $this->cleaner = $cleaner; } public function getCodeCleaner() : CodeCleaner { if (!isset($this->cleaner)) { $this->cleaner = new CodeCleaner(null, null, null, $this->yolo(), $this->strictTypes()); } return $this->cleaner; } public function setYolo($yolo) { $this->yolo = (bool) $yolo; } public function yolo() : bool { return $this->yolo; } public function setUseTabCompletion(bool $useTabCompletion) { $this->useTabCompletion = (bool) $useTabCompletion; } public function setTabCompletion(bool $useTabCompletion) { @\trigger_error("\140\163\145\x74\124\141\x62\103\x6f\155\160\154\145\x74\151\x6f\156\x60\x20\x69\x73\x20\144\x65\160\162\x65\143\x61\164\145\x64\x3b\40\143\x61\x6c\x6c\x20\x60\x73\x65\164\x55\163\x65\x54\x61\x62\103\x6f\155\x70\x6c\x65\164\x69\157\156\140\40\151\x6e\163\x74\145\141\144\x2e", \E_USER_DEPRECATED); $this->setUseTabCompletion($useTabCompletion); } public function useTabCompletion() : bool { return isset($this->useTabCompletion) ? $this->hasReadline && $this->useTabCompletion : $this->hasReadline; } public function getTabCompletion() : bool { @\trigger_error("\140\x67\145\164\124\x61\142\x43\157\155\160\154\145\x74\x69\157\156\x60\x20\151\x73\40\x64\145\x70\162\x65\143\141\x74\145\144\73\x20\x63\x61\154\154\x20\140\x75\163\x65\x54\141\142\103\x6f\x6d\x70\x6c\x65\164\151\x6f\x6e\140\x20\x69\x6e\x73\164\x65\141\x64\x2e", \E_USER_DEPRECATED); return $this->useTabCompletion(); } public function setOutput(ShellOutput $output) { $this->output = $output; $this->pipedOutput = null; if (isset($this->theme)) { $output->setTheme($this->theme); } $this->applyFormatterStyles(); } public function getOutput() : ShellOutput { if (!isset($this->output)) { $this->setOutput(new ShellOutput($this->getOutputVerbosity(), null, null, $this->getPager() ?: null, $this->theme())); $decorated = $this->getOutputDecorated(); if ($decorated !== null) { $this->output->setDecorated($decorated); } } return $this->output; } public function getOutputDecorated() { switch ($this->colorMode()) { case self::COLOR_MODE_FORCED: return true; case self::COLOR_MODE_DISABLED: return false; case self::COLOR_MODE_AUTO: default: return $this->outputIsPiped() ? false : null; } } public function getInputInteractive() : bool { switch ($this->interactiveMode()) { case self::INTERACTIVE_MODE_FORCED: return true; case self::INTERACTIVE_MODE_DISABLED: return false; case self::INTERACTIVE_MODE_AUTO: default: return !$this->inputIsPiped(); } } public function setPager($pager) { if ($pager === null || $pager === false || $pager === "\143\141\x74") { $pager = false; } if ($pager !== false && !\is_string($pager) && !$pager instanceof OutputPager) { throw new \InvalidArgumentException("\125\156\145\170\160\x65\x63\x74\145\144\40\160\141\x67\145\x72\x20\x69\x6e\x73\164\x61\x6e\143\145"); } $this->pager = $pager; } public function getPager() { if (!isset($this->pager) && $this->usePcntl()) { if (\getenv("\124\x45\122\x4d") === "\144\x75\x6d\x62") { return false; } if ($pager = \ini_get("\x63\154\151\x2e\160\x61\x67\x65\x72")) { $this->pager = $pager; } elseif ($less = $this->configPaths->which("\154\x65\x73\x73")) { $link = @\readlink($less); if ($link !== false && \strpos($link, "\x62\x75\163\x79\142\x6f\170") !== false) { return false; } $this->pager = $less . "\x20\x2d\x52\40\55\x46\40\55\x58"; } } return $this->pager; } public function setAutoCompleter(AutoCompleter $autoCompleter) { $this->autoCompleter = $autoCompleter; } public function getAutoCompleter() : AutoCompleter { if (!isset($this->autoCompleter)) { $this->autoCompleter = new AutoCompleter(); } return $this->autoCompleter; } public function getTabCompletionMatchers() : array { @\trigger_error("\140\x67\x65\164\x54\141\142\103\x6f\x6d\x70\154\145\164\151\x6f\x6e\115\x61\164\x63\150\145\162\x73\140\x20\151\x73\x20\156\157\40\x6c\x6f\x6e\x67\145\162\x20\x75\163\145\144\x2e", \E_USER_DEPRECATED); return array(); } public function addMatchers(array $matchers) { $this->newMatchers = \array_merge($this->newMatchers, $matchers); if (isset($this->shell)) { $this->doAddMatchers(); } } private function doAddMatchers() { if (!empty($this->newMatchers)) { $this->shell->addMatchers($this->newMatchers); $this->newMatchers = array(); } } public function addTabCompletionMatchers(array $matchers) { @\trigger_error("\140\141\144\144\124\x61\142\x43\157\x6d\x70\154\145\164\151\157\x6e\x4d\141\164\x63\150\x65\x72\x73\140\40\x69\163\x20\x64\x65\x70\x72\145\143\x61\164\x65\144\x3b\40\x63\141\x6c\154\40\140\141\144\144\115\x61\164\143\x68\145\x72\163\140\x20\151\156\163\164\x65\141\x64\x2e", \E_USER_DEPRECATED); $this->addMatchers($matchers); } public function addCommands(array $commands) { $this->newCommands = \array_merge($this->newCommands, $commands); if (isset($this->shell)) { $this->doAddCommands(); } } private function doAddCommands() { if (!empty($this->newCommands)) { $this->shell->addCommands($this->newCommands); $this->newCommands = array(); } } public function setShell(Shell $shell) { $this->shell = $shell; $this->doAddCommands(); $this->doAddMatchers(); } public function setManualDbFile(string $filename) { $this->manualDbFile = (string) $filename; } public function getManualDbFile() { if (isset($this->manualDbFile)) { return $this->manualDbFile; } $files = $this->configPaths->dataFiles(array("\160\x68\x70\x5f\155\141\x6e\165\141\x6c\x2e\x73\161\x6c\151\164\145")); if (!empty($files)) { if ($this->warnOnMultipleConfigs && \count($files) > 1) { $msg = \sprintf("\x4d\165\x6c\164\x69\x70\x6c\x65\40\x6d\141\156\165\141\x6c\40\144\x61\164\x61\142\141\x73\x65\40\146\151\154\x65\x73\x20\146\x6f\x75\156\x64\72\x20\x25\x73\x2e\40\125\x73\x69\x6e\x67\x20\x25\163", \implode("\54\x20", $files), $files[0]); \trigger_error($msg, \E_USER_NOTICE); } return $this->manualDbFile = $files[0]; } } public function getManualDb() { if (!isset($this->manualDb)) { $dbFile = $this->getManualDbFile(); if ($dbFile !== null && \is_file($dbFile)) { try { $this->manualDb = new \PDO("\163\161\x6c\151\x74\145\x3a" . $dbFile); } catch (\PDOException $e) { if ($e->getMessage() === "\x63\x6f\x75\x6c\144\x20\156\x6f\164\40\146\151\156\x64\40\144\x72\151\x76\145\x72") { throw new RuntimeException("\123\x51\114\151\164\x65\x20\120\x44\117\x20\144\162\x69\x76\145\162\x20\156\x6f\164\x20\x66\157\165\x6e\x64", 0, $e); } else { throw $e; } } } } return $this->manualDb; } public function addCasters(array $casters) { $this->getPresenter()->addCasters($casters); } public function getPresenter() : Presenter { if (!isset($this->presenter)) { $this->presenter = new Presenter($this->getOutput()->getFormatter(), $this->forceArrayIndexes()); } return $this->presenter; } public function setWarnOnMultipleConfigs(bool $warnOnMultipleConfigs) { $this->warnOnMultipleConfigs = (bool) $warnOnMultipleConfigs; } public function warnOnMultipleConfigs() : bool { return $this->warnOnMultipleConfigs; } public function setColorMode(string $colorMode) { $validColorModes = array(self::COLOR_MODE_AUTO, self::COLOR_MODE_FORCED, self::COLOR_MODE_DISABLED); if (!\in_array($colorMode, $validColorModes)) { throw new \InvalidArgumentException("\x49\156\166\x61\x6c\151\x64\40\x63\157\x6c\157\x72\x20\155\157\x64\x65\72\x20" . $colorMode); } $this->colorMode = $colorMode; } public function colorMode() : string { return $this->colorMode; } public function setInteractiveMode(string $interactiveMode) { $validInteractiveModes = array(self::INTERACTIVE_MODE_AUTO, self::INTERACTIVE_MODE_FORCED, self::INTERACTIVE_MODE_DISABLED); if (!\in_array($interactiveMode, $validInteractiveModes)) { throw new \InvalidArgumentException("\x49\156\166\x61\x6c\151\x64\x20\x69\156\x74\x65\x72\x61\143\x74\x69\166\x65\x20\x6d\157\144\x65\72\x20" . $interactiveMode); } $this->interactiveMode = $interactiveMode; } public function interactiveMode() : string { return $this->interactiveMode; } public function setChecker(Checker $checker) { $this->checker = $checker; } public function getChecker() : Checker { if (!isset($this->checker)) { $interval = $this->getUpdateCheck(); switch ($interval) { case Checker::ALWAYS: $this->checker = new GitHubChecker(); break; case Checker::DAILY: case Checker::WEEKLY: case Checker::MONTHLY: $checkFile = $this->getUpdateCheckCacheFile(); if ($checkFile === false) { $this->checker = new NoopChecker(); } else { $this->checker = new IntervalChecker($checkFile, $interval); } break; case Checker::NEVER: $this->checker = new NoopChecker(); break; } } return $this->checker; } public function getUpdateCheck() : string { return isset($this->updateCheck) ? $this->updateCheck : Checker::WEEKLY; } public function setUpdateCheck(string $interval) { $validIntervals = array(Checker::ALWAYS, Checker::DAILY, Checker::WEEKLY, Checker::MONTHLY, Checker::NEVER); if (!\in_array($interval, $validIntervals)) { throw new \InvalidArgumentException("\x49\x6e\166\141\x6c\x69\x64\x20\x75\x70\x64\x61\164\145\x20\x63\150\145\x63\x6b\40\151\x6e\x74\x65\162\x76\x61\x6c\72\x20" . $interval); } $this->updateCheck = $interval; } public function getUpdateCheckCacheFile() { return ConfigPaths::touchFileWithMkdir($this->configPaths->currentConfigDir() . "\x2f\165\160\x64\x61\x74\x65\x5f\143\150\x65\143\x6b\x2e\x6a\163\157\x6e"); } public function setStartupMessage(string $message) { $this->startupMessage = $message; } public function getStartupMessage() { return $this->startupMessage; } public function setPrompt(string $prompt) { $this->prompt = $prompt; if (isset($this->theme)) { $this->theme->setPrompt($prompt); } } public function getPrompt() { return $this->prompt; } public function forceArrayIndexes() : bool { return $this->forceArrayIndexes; } public function setForceArrayIndexes(bool $forceArrayIndexes) { $this->forceArrayIndexes = $forceArrayIndexes; } public function setTheme($theme) { if (!$theme instanceof Theme) { $theme = new Theme($theme); } $this->theme = $theme; if (isset($this->prompt)) { $this->theme->setPrompt($this->prompt); } if (isset($this->output)) { $this->output->setTheme($theme); $this->applyFormatterStyles(); } } public function theme() : Theme { if (!isset($this->theme)) { $this->theme = $this->prompt ? new Theme("\143\154\x61\163\163\151\143") : new Theme(); } if (isset($this->prompt)) { $this->theme->setPrompt($this->prompt); } return $this->theme; } public function setFormatterStyles(array $formatterStyles) { foreach ($formatterStyles as $name => $style) { $this->formatterStyles[$name] = new OutputFormatterStyle(...$style); } if (isset($this->output)) { $this->applyFormatterStyles(); } } private function applyFormatterStyles() { $formatter = $this->output->getFormatter(); foreach ($this->formatterStyles as $name => $style) { $formatter->setStyle($name, $style); } $errorFormatter = $this->output->getErrorOutput()->getFormatter(); foreach (Theme::ERROR_STYLES as $name) { if (isset($this->formatterStyles[$name])) { $errorFormatter->setStyle($name, $this->formatterStyles[$name]); } } } public function verbosity() : string { return $this->verbosity; } public function setVerbosity(string $verbosity) { $validVerbosityLevels = array(self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE, self::VERBOSITY_VERY_VERBOSE, self::VERBOSITY_DEBUG); if (!\in_array($verbosity, $validVerbosityLevels)) { throw new \InvalidArgumentException("\111\x6e\x76\141\x6c\x69\x64\40\166\145\162\142\157\x73\151\x74\171\40\154\145\166\145\154\x3a\40" . $verbosity); } $this->verbosity = $verbosity; if (isset($this->output)) { $this->output->setVerbosity($this->getOutputVerbosity()); } } public function getOutputVerbosity() : int { switch ($this->verbosity()) { case self::VERBOSITY_QUIET: return OutputInterface::VERBOSITY_QUIET; case self::VERBOSITY_VERBOSE: return OutputInterface::VERBOSITY_VERBOSE; case self::VERBOSITY_VERY_VERBOSE: return OutputInterface::VERBOSITY_VERY_VERBOSE; case self::VERBOSITY_DEBUG: return OutputInterface::VERBOSITY_DEBUG; case self::VERBOSITY_NORMAL: default: return OutputInterface::VERBOSITY_NORMAL; } } public function inputIsPiped() : bool { if ($this->pipedInput === null) { $this->pipedInput = \defined("\123\124\104\x49\116") && self::looksLikeAPipe(\STDIN); } return $this->pipedInput; } public function outputIsPiped() : bool { if ($this->pipedOutput === null) { $this->pipedOutput = self::looksLikeAPipe($this->getOutput()->getStream()); } return $this->pipedOutput; } private static function looksLikeAPipe($stream) : bool { if (\function_exists("\x70\157\163\151\x78\137\151\x73\x61\x74\x74\171")) { return !\posix_isatty($stream); } $stat = \fstat($stream); $mode = $stat["\155\157\144\145"] & 61440; return $mode === 4096 || $mode === 16384 || $mode === 32768 || $mode === 40960; } }

Function Calls

None

Variables

None

Stats

MD5 3228ebac39ca69c5c59d3d36946b72ed
Eval Count 0
Decode Time 126 ms