X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCommand%2FTraceCommand.php;fp=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCommand%2FTraceCommand.php;h=00e5903fd9eae0500dfa4136e95ebbac1a5e2cc1;hp=72db281dc25ab9d1ee32a3d59bc9e470db1e5bbd;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae diff --git a/vendor/psy/psysh/src/Psy/Command/TraceCommand.php b/vendor/psy/psysh/src/Psy/Command/TraceCommand.php index 72db281dc..00e5903fd 100644 --- a/vendor/psy/psysh/src/Psy/Command/TraceCommand.php +++ b/vendor/psy/psysh/src/Psy/Command/TraceCommand.php @@ -11,6 +11,7 @@ namespace Psy\Command; +use Psy\Input\FilterOptions; use Psy\Output\ShellOutput; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Input\InputInterface; @@ -22,16 +23,34 @@ use Symfony\Component\Console\Output\OutputInterface; */ class TraceCommand extends Command { + protected $filter; + + /** + * {@inheritdoc} + */ + public function __construct($name = null) + { + $this->filter = new FilterOptions(); + + parent::__construct($name); + } + /** * {@inheritdoc} */ protected function configure() { + list($grep, $insensitive, $invert) = FilterOptions::getOptions(); + $this ->setName('trace') ->setDefinition(array( new InputOption('include-psy', 'p', InputOption::VALUE_NONE, 'Include Psy in the call stack.'), new InputOption('num', 'n', InputOption::VALUE_REQUIRED, 'Only include NUM lines.'), + + $grep, + $insensitive, + $invert, )) ->setDescription('Show the current call stack.') ->setHelp( @@ -52,6 +71,7 @@ HELP */ protected function execute(InputInterface $input, OutputInterface $output) { + $this->filter->bind($input); $trace = $this->getBacktrace(new \Exception(), $input->getOption('num'), $input->getOption('include-psy')); $output->page($trace, ShellOutput::NUMBER_LINES); } @@ -105,6 +125,16 @@ HELP $file = isset($trace[$i]['file']) ? $this->replaceCwd($cwd, $trace[$i]['file']) : 'n/a'; $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; + // Leave execution loop out of the `eval()'d code` lines + if (preg_match("#/Psy/ExecutionLoop/Loop.php\(\d+\) : eval\(\)'d code$#", $file)) { + $file = "eval()'d code"; + } + + // Skip any lines that don't match our filter options + if (!$this->filter->match(sprintf('%s%s%s() at %s:%s', $class, $type, $function, $file, $line))) { + continue; + } + $lines[] = sprintf( ' %s%s%s() at %s:%s', OutputFormatter::escape($class),