comparison vendor/psy/psysh/src/Command/WtfCommand.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
84 */ 84 */
85 protected function execute(InputInterface $input, OutputInterface $output) 85 protected function execute(InputInterface $input, OutputInterface $output)
86 { 86 {
87 $this->filter->bind($input); 87 $this->filter->bind($input);
88 88
89 $incredulity = implode('', $input->getArgument('incredulity')); 89 $incredulity = \implode('', $input->getArgument('incredulity'));
90 if (strlen(preg_replace('/[\\?!]/', '', $incredulity))) { 90 if (\strlen(\preg_replace('/[\\?!]/', '', $incredulity))) {
91 throw new \InvalidArgumentException('Incredulity must include only "?" and "!"'); 91 throw new \InvalidArgumentException('Incredulity must include only "?" and "!"');
92 } 92 }
93 93
94 $exception = $this->context->getLastException(); 94 $exception = $this->context->getLastException();
95 $count = $input->getOption('all') ? PHP_INT_MAX : max(3, pow(2, strlen($incredulity) + 1)); 95 $count = $input->getOption('all') ? PHP_INT_MAX : \max(3, \pow(2, \strlen($incredulity) + 1));
96 96
97 $shell = $this->getApplication(); 97 $shell = $this->getApplication();
98 $output->startPaging(); 98 $output->startPaging();
99 do { 99 do {
100 $traceCount = count($exception->getTrace()); 100 $traceCount = \count($exception->getTrace());
101 $showLines = $count; 101 $showLines = $count;
102 // Show the whole trace if we'd only be hiding a few lines 102 // Show the whole trace if we'd only be hiding a few lines
103 if ($traceCount < max($count * 1.2, $count + 2)) { 103 if ($traceCount < \max($count * 1.2, $count + 2)) {
104 $showLines = PHP_INT_MAX; 104 $showLines = PHP_INT_MAX;
105 } 105 }
106 106
107 $trace = $this->getBacktrace($exception, $showLines); 107 $trace = $this->getBacktrace($exception, $showLines);
108 $moreLines = $traceCount - count($trace); 108 $moreLines = $traceCount - \count($trace);
109 109
110 $output->writeln($shell->formatException($exception)); 110 $output->writeln($shell->formatException($exception));
111 $output->writeln('--'); 111 $output->writeln('--');
112 $output->write($trace, true, ShellOutput::NUMBER_LINES); 112 $output->write($trace, true, ShellOutput::NUMBER_LINES);
113 $output->writeln(''); 113 $output->writeln('');
114 114
115 if ($moreLines > 0) { 115 if ($moreLines > 0) {
116 $output->writeln(sprintf( 116 $output->writeln(\sprintf(
117 '<aside>Use <return>wtf -a</return> to see %d more lines</aside>', 117 '<aside>Use <return>wtf -a</return> to see %d more lines</aside>',
118 $moreLines 118 $moreLines
119 )); 119 ));
120 $output->writeln(''); 120 $output->writeln('');
121 } 121 }