public function __construct($colorMode = null)
{
$this->colorMode = $colorMode ?: Configuration::COLOR_MODE_AUTO;
- $this->backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+ $this->backtrace = \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
parent::__construct();
}
*/
protected function trace()
{
- foreach (array_reverse($this->backtrace) as $stackFrame) {
+ foreach (\array_reverse($this->backtrace) as $stackFrame) {
if ($this->isDebugCall($stackFrame)) {
return $stackFrame;
}
}
- return end($this->backtrace);
+ return \end($this->backtrace);
}
private static function isDebugCall(array $stackFrame)
$function = isset($stackFrame['function']) ? $stackFrame['function'] : null;
return ($class === null && $function === 'Psy\debug') ||
- ($class === 'Psy\Shell' && in_array($function, ['__construct', 'debug']));
+ ($class === 'Psy\Shell' && \in_array($function, ['__construct', 'debug']));
}
/**
protected function fileInfo()
{
$stackFrame = $this->trace();
- if (preg_match('/eval\(/', $stackFrame['file'])) {
- preg_match_all('/([^\(]+)\((\d+)/', $stackFrame['file'], $matches);
+ if (\preg_match('/eval\(/', $stackFrame['file'])) {
+ \preg_match_all('/([^\(]+)\((\d+)/', $stackFrame['file'], $matches);
$file = $matches[1][0];
$line = (int) $matches[2][0];
} else {
$line = $stackFrame['line'];
}
- return compact('file', 'line');
+ return \compact('file', 'line');
}
/**
$factory = new ConsoleColorFactory($this->colorMode);
$colors = $factory->getConsoleColor();
$highlighter = new Highlighter($colors);
- $contents = file_get_contents($info['file']);
+ $contents = \file_get_contents($info['file']);
$output->startPaging();
$output->writeln('');
- $output->writeln(sprintf('From <info>%s:%s</info>:', $this->replaceCwd($info['file']), $info['line']));
+ $output->writeln(\sprintf('From <info>%s:%s</info>:', $this->replaceCwd($info['file']), $info['line']));
$output->writeln('');
$output->write($highlighter->getCodeSnippet($contents, $info['line'], $num, $num), ShellOutput::OUTPUT_RAW);
$output->stopPaging();
*/
private function replaceCwd($file)
{
- $cwd = getcwd();
+ $cwd = \getcwd();
if ($cwd === false) {
return $file;
}
- $cwd = rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
+ $cwd = \rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
- return preg_replace('/^' . preg_quote($cwd, '/') . '/', '', $file);
+ return \preg_replace('/^' . \preg_quote($cwd, '/') . '/', '', $file);
}
}