Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/src/Command/ShowCommand.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 5fb285c0d0e3 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
138 $index = $this->lastExceptionIndex + 1; | 138 $index = $this->lastExceptionIndex + 1; |
139 } else { | 139 } else { |
140 $index = 0; | 140 $index = 0; |
141 } | 141 } |
142 } else { | 142 } else { |
143 $index = max(0, intval($input->getOption('ex')) - 1); | 143 $index = \max(0, \intval($input->getOption('ex')) - 1); |
144 } | 144 } |
145 | 145 |
146 $trace = $exception->getTrace(); | 146 $trace = $exception->getTrace(); |
147 array_unshift($trace, [ | 147 \array_unshift($trace, [ |
148 'file' => $exception->getFile(), | 148 'file' => $exception->getFile(), |
149 'line' => $exception->getLine(), | 149 'line' => $exception->getLine(), |
150 ]); | 150 ]); |
151 | 151 |
152 if ($index >= count($trace)) { | 152 if ($index >= \count($trace)) { |
153 $index = 0; | 153 $index = 0; |
154 } | 154 } |
155 | 155 |
156 $this->lastException = $exception; | 156 $this->lastException = $exception; |
157 $this->lastExceptionIndex = $index; | 157 $this->lastExceptionIndex = $index; |
167 private function writeTraceLine(OutputInterface $output, array $trace, $index) | 167 private function writeTraceLine(OutputInterface $output, array $trace, $index) |
168 { | 168 { |
169 $file = isset($trace[$index]['file']) ? $this->replaceCwd($trace[$index]['file']) : 'n/a'; | 169 $file = isset($trace[$index]['file']) ? $this->replaceCwd($trace[$index]['file']) : 'n/a'; |
170 $line = isset($trace[$index]['line']) ? $trace[$index]['line'] : 'n/a'; | 170 $line = isset($trace[$index]['line']) ? $trace[$index]['line'] : 'n/a'; |
171 | 171 |
172 $output->writeln(sprintf( | 172 $output->writeln(\sprintf( |
173 'From <info>%s:%d</info> at <strong>level %d</strong> of backtrace (of %d).', | 173 'From <info>%s:%d</info> at <strong>level %d</strong> of backtrace (of %d).', |
174 OutputFormatter::escape($file), | 174 OutputFormatter::escape($file), |
175 OutputFormatter::escape($line), | 175 OutputFormatter::escape($line), |
176 $index + 1, | 176 $index + 1, |
177 count($trace) | 177 \count($trace) |
178 )); | 178 )); |
179 } | 179 } |
180 | 180 |
181 private function replaceCwd($file) | 181 private function replaceCwd($file) |
182 { | 182 { |
183 if ($cwd = getcwd()) { | 183 if ($cwd = \getcwd()) { |
184 $cwd = rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; | 184 $cwd = \rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
185 } | 185 } |
186 | 186 |
187 if ($cwd === false) { | 187 if ($cwd === false) { |
188 return $file; | 188 return $file; |
189 } else { | 189 } else { |
190 return preg_replace('/^' . preg_quote($cwd, '/') . '/', '', $file); | 190 return \preg_replace('/^' . \preg_quote($cwd, '/') . '/', '', $file); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 private function writeTraceCodeSnippet(OutputInterface $output, array $trace, $index) | 194 private function writeTraceCodeSnippet(OutputInterface $output, array $trace, $index) |
195 { | 195 { |
206 } | 206 } |
207 | 207 |
208 $line = $trace[$index]['line']; | 208 $line = $trace[$index]['line']; |
209 } | 209 } |
210 | 210 |
211 if (is_file($file)) { | 211 if (\is_file($file)) { |
212 $code = @file_get_contents($file); | 212 $code = @\file_get_contents($file); |
213 } | 213 } |
214 | 214 |
215 if (empty($code)) { | 215 if (empty($code)) { |
216 return; | 216 return; |
217 } | 217 } |
266 list($file, $line) = $fileAndLine; | 266 list($file, $line) = $fileAndLine; |
267 } elseif (isset($context['line'])) { | 267 } elseif (isset($context['line'])) { |
268 $line = $context['line']; | 268 $line = $context['line']; |
269 } | 269 } |
270 | 270 |
271 if (is_file($file)) { | 271 if (\is_file($file)) { |
272 $vars['__file'] = $file; | 272 $vars['__file'] = $file; |
273 if (isset($line)) { | 273 if (isset($line)) { |
274 $vars['__line'] = $line; | 274 $vars['__line'] = $line; |
275 } | 275 } |
276 $vars['__dir'] = dirname($file); | 276 $vars['__dir'] = \dirname($file); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 $this->context->setCommandScopeVariables($vars); | 280 $this->context->setCommandScopeVariables($vars); |
281 } | 281 } |
282 | 282 |
283 private function extractEvalFileAndLine($file) | 283 private function extractEvalFileAndLine($file) |
284 { | 284 { |
285 if (preg_match('/(.*)\\((\\d+)\\) : eval\\(\\)\'d code$/', $file, $matches)) { | 285 if (\preg_match('/(.*)\\((\\d+)\\) : eval\\(\\)\'d code$/', $file, $matches)) { |
286 return [$matches[1], $matches[2]]; | 286 return [$matches[1], $matches[2]]; |
287 } | 287 } |
288 } | 288 } |
289 } | 289 } |