Mercurial > hg > cmmr2012-drupal-site
diff vendor/psy/psysh/src/Command/HistoryCommand.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 |
line wrap: on
line diff
--- a/vendor/psy/psysh/src/Command/HistoryCommand.php Thu Feb 28 11:14:44 2019 +0000 +++ b/vendor/psy/psysh/src/Command/HistoryCommand.php Thu Feb 28 13:11:55 2019 +0000 @@ -110,11 +110,11 @@ foreach ($history as $i => $line) { if ($this->filter->match($line, $matches)) { if (isset($matches[0])) { - $chunks = explode($matches[0], $history[$i]); - $chunks = array_map([__CLASS__, 'escape'], $chunks); - $glue = sprintf('<urgent>%s</urgent>', self::escape($matches[0])); + $chunks = \explode($matches[0], $history[$i]); + $chunks = \array_map([__CLASS__, 'escape'], $chunks); + $glue = \sprintf('<urgent>%s</urgent>', self::escape($matches[0])); - $highlighted[$i] = implode($glue, $chunks); + $highlighted[$i] = \implode($glue, $chunks); } } else { unset($history[$i]); @@ -123,16 +123,16 @@ } if ($save = $input->getOption('save')) { - $output->writeln(sprintf('Saving history in %s...', $save)); - file_put_contents($save, implode(PHP_EOL, $history) . PHP_EOL); + $output->writeln(\sprintf('Saving history in %s...', $save)); + \file_put_contents($save, \implode(PHP_EOL, $history) . PHP_EOL); $output->writeln('<info>History saved.</info>'); } elseif ($input->getOption('replay')) { if (!($input->getOption('show') || $input->getOption('head') || $input->getOption('tail'))) { throw new \InvalidArgumentException('You must limit history via --head, --tail or --show before replaying'); } - $count = count($history); - $output->writeln(sprintf('Replaying %d line%s of history', $count, ($count !== 1) ? 's' : '')); + $count = \count($history); + $output->writeln(\sprintf('Replaying %d line%s of history', $count, ($count !== 1) ? 's' : '')); $this->getApplication()->addInput($history); } elseif ($input->getOption('clear')) { $this->clearHistory(); @@ -156,14 +156,14 @@ */ private function extractRange($range) { - if (preg_match('/^\d+$/', $range)) { + if (\preg_match('/^\d+$/', $range)) { return [$range, $range + 1]; } $matches = []; - if ($range !== '..' && preg_match('/^(\d*)\.\.(\d*)$/', $range, $matches)) { - $start = $matches[1] ? intval($matches[1]) : 0; - $end = $matches[2] ? intval($matches[2]) + 1 : PHP_INT_MAX; + if ($range !== '..' && \preg_match('/^(\d*)\.\.(\d*)$/', $range, $matches)) { + $start = $matches[1] ? \intval($matches[1]) : 0; + $end = $matches[2] ? \intval($matches[2]) + 1 : PHP_INT_MAX; return [$start, $end]; } @@ -185,30 +185,30 @@ $history = $this->readline->listHistory(); // don't show the current `history` invocation - array_pop($history); + \array_pop($history); if ($show) { list($start, $end) = $this->extractRange($show); $length = $end - $start; } elseif ($head) { - if (!preg_match('/^\d+$/', $head)) { + if (!\preg_match('/^\d+$/', $head)) { throw new \InvalidArgumentException('Please specify an integer argument for --head'); } $start = 0; - $length = intval($head); + $length = \intval($head); } elseif ($tail) { - if (!preg_match('/^\d+$/', $tail)) { + if (!\preg_match('/^\d+$/', $tail)) { throw new \InvalidArgumentException('Please specify an integer argument for --tail'); } - $start = count($history) - $tail; - $length = intval($tail) + 1; + $start = \count($history) - $tail; + $length = \intval($tail) + 1; } else { return $history; } - return array_slice($history, $start, $length, true); + return \array_slice($history, $start, $length, true); } /** @@ -227,7 +227,7 @@ } if ($count > 1) { - throw new \InvalidArgumentException('Please specify only one of --' . implode(', --', $options)); + throw new \InvalidArgumentException('Please specify only one of --' . \implode(', --', $options)); } }