Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / psy / psysh / src / Command / HistoryCommand.php
index eef8ef9d0905c5348f26ba03327c32a0a2881303..23f6899e324fc5951090ee30842518888229d550 100644 (file)
@@ -110,11 +110,11 @@ HELP
             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 @@ HELP
         }
 
         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 @@ HELP
      */
     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 @@ HELP
         $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 @@ HELP
         }
 
         if ($count > 1) {
-            throw new \InvalidArgumentException('Please specify only one of --' . implode(', --', $options));
+            throw new \InvalidArgumentException('Please specify only one of --' . \implode(', --', $options));
         }
     }