SHARE
TWEET

Untitled

a guest Jul 17th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.         $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  3.     }
  4.  
  5.     /**
  6.      * {@inheritdoc}
  7.      */
  8.     public function caution($message)
  9.     {
  10.         $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  11.     }
  12.  
  13.     /**
  14.      * {@inheritdoc}
  15.      */
  16.     public function table(array $headers, array $rows)
  17.     {
  18.         $style = clone Table::getStyleDefinition('symfony-style-guide');
  19.         $style->setCellHeaderFormat('<info>%s</info>');
  20.  
  21.         $table = new Table($this);
  22.         $table->setHeaders($headers);
  23.         $table->setRows($rows);
  24.         $table->setStyle($style);
  25.  
  26.         $table->render();
  27.         $this->newLine();
  28.     }
  29.  
  30.     /**
  31.      * {@inheritdoc}
  32.      */
  33.     public function ask($question, $default = null, $validator = null)
  34.     {
  35.         $question = new Question($question, $default);
  36.         $question->setValidator($validator);
  37.  
  38.         return $this->askQuestion($question);
  39.     }
  40.  
  41.     /**
  42.      * {@inheritdoc}
  43.      */
  44.     public function askHidden($question, $validator = null)
  45.     {
  46.         $question = new Question($question);
  47.  
  48.         $question->setHidden(true);
  49.         $question->setValidator($validator);
  50.  
  51.         return $this->askQuestion($question);
  52.     }
  53.  
  54.     /**
  55.      * {@inheritdoc}
  56.      */
  57.     public function confirm($question, $default = true)
  58.     {
  59.         return $this->askQuestion(new ConfirmationQuestion($question, $default));
  60.     }
  61.  
  62.     /**
  63.      * {@inheritdoc}
  64.      */
  65.     public function choice($question, array $choices, $default = null)
  66.     {
  67.         if (null !== $default) {
  68.             $values = array_flip($choices);
  69.             $default = $values[$default];
  70.         }
  71.  
  72.         return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  73.     }
  74.  
  75.     /**
  76.      * {@inheritdoc}
  77.      */
  78.     public function progressStart($max = 0)
  79.     {
  80.         $this->progressBar = $this->createProgressBar($max);
  81.         $this->progressBar->start();
  82.     }
  83.  
  84.     /**
  85.      * {@inheritdoc}
  86.      */
  87.     public function progressAdvance($step = 1)
  88.     {
  89.         $this->getProgressBar()->advance($step);
  90.     }
  91.  
  92.     /**
  93.      * {@inheritdoc}
  94.      */
  95.     public function progressFinish()
  96.     {
  97.         $this->getProgressBar()->finish();
  98.         $this->newLine(2);
  99.         $this->progressBar = null;
  100.     }
  101.  
  102.     /**
  103.      * {@inheritdoc}
  104.      */
  105.     public function createProgressBar($max = 0)
  106.     {
  107.         $progressBar = parent::createProgressBar($max);
  108.  
  109.         if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  110.             $progressBar->setEmptyBarCharacter('Ôûæ'); // light shade character \u2591
  111.             $progressBar->setProgressCharacter('');
  112.             $progressBar->setBarCharacter('Ôûô'); // dark shade character \u2593
  113.         }
  114.  
  115.         return $progressBar;
  116.     }
  117.  
  118.     /**
  119.      * @return mixed
  120.      */
  121.     public function askQuestion(Question $question)
  122.     {
  123.         if ($this->input->isInteractive()) {
  124.             $this->autoPrependBlock();
  125.         }
  126.  
  127.         if (!$this->questionHelper) {
  128.             $this->questionHelper = new SymfonyQuestionHelper();
  129.         }
  130.  
  131.         $answer = $this->questionHelper->ask($this->input, $this, $question);
  132.  
  133.         if ($this->input->isInteractive()) {
  134.             $this->newLine();
  135.             $this->bufferedOutput->write("\n");
  136.         }
  137.  
  138.         return $answer;
  139.     }
  140.  
  141.     /**
  142.      * {@inheritdoc}
  143.      */
  144.     public function writeln($messages, $type = self::OUTPUT_NORMAL)
  145.     {
  146.         if (!is_iterable($messages)) {
  147.             $messages = array($messages);
  148.         }
  149.  
  150.         foreach ($messages as $message) {
  151.             parent::writeln($message, $type);
  152.             $this->writeBuffer($message, true, $type);
  153.         }
  154.     }
  155.  
  156.     /**
  157.      * {@inheritdoc}
  158.      */
  159.     public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  160.     {
  161.         if (!is_iterable($messages)) {
  162.             $messages = array($messages);
  163.         }
  164.  
  165.         foreach ($messages as $message) {
  166.             parent::write($message, $newline, $type);
  167.             $this->writeBuffer($message, $newline, $type);
  168.         }
  169.     }
  170.  
  171.     /**
  172.      * {@inheritdoc}
  173.      */
  174.     public function newLine($count = 1)
  175.     {
  176.         parent::newLine($count);
  177.         $this->bufferedOutput->write(str_repeat("\n", $count));
  178.     }
  179.  
  180.     /**
  181.      * Returns a new instance which makes use of stderr if available.
  182.      *
  183.      * @return self
  184.      */
  185.     public function getErrorStyle()
  186.     {
  187.         return new self($this->input, $this->getErrorOutput());
  188.     }
  189.  
  190.     private function getProgressBar(): ProgressBar
  191.     {
  192.         if (!$this->progressBar) {
  193.             throw new RuntimeException('The ProgressBar is not started.');
  194.         }
  195.  
  196.         return $this->progressBar;
  197.     }
  198.  
  199.     private function autoPrependBlock(): void
  200.     {
  201.         $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  202.  
  203.         if (!isset($chars[0])) {
  204.             $this->newLine(); //empty history, so we should start with a new line.
  205.  
  206.             return;
  207.         }
  208.         //Prepend new line for each non LF chars (This means no blank line was output before)
  209.         $this->newLine(2 - substr_count($chars, "\n"));
  210.     }
  211.  
  212.     private function autoPrependText(): void
  213.     {
  214.         $fetched = $this->bufferedOutput->fetch();
  215.         //Prepend new line if last char isn't EOL:
  216.         if ("\n" !== substr($fetched, -1)) {
  217.             $this->newLine();
  218.         }
  219.     }
  220.  
  221.     private function writeBuffer(string $message, bool $newLine, int $type): void
  222.     {
  223.         // We need to know if the two last chars are PHP_EOL
  224.         // Preserve the last 4 chars inserted (PHP_EOL on windows is two chars) in the history buffer
  225.         $this->bufferedOutput->write(substr($message, -4), $newLine, $type);
  226.     }
  227.  
  228.     private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false)
  229.     {
  230.         $indentLength = 0;
  231.         $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  232.         $lines = array();
  233.  
  234.         if (null !== $type) {
  235.             $type = sprintf('[%s] ', $type);
  236.             $indentLength = \strlen($type);
  237.             $lineIndentation = str_repeat(' ', $indentLength);
  238.         }
  239.  
  240.         // wrap and add newlines for each element
  241.         foreach ($messages as $key => $message) {
  242.             if ($escape) {
  243.                 $message = OutputFormatter::escape($message);
  244.             }
  245.  
  246.             $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  247.  
  248.             if (\count($messages) > 1 && $key < \count($messages) - 1) {
  249.                 $lines[] = '';
  250.             }
  251.         }
  252.  
  253.         $firstLineIndex = 0;
  254.         if ($padding && $this->isDecorated()) {
  255.             $firstLineIndex = 1;
  256.             array_unshift($lines, '');
  257.             $lines[] = '';
  258.         }
  259.  
  260.         foreach ($lines as $i => &$line) {
  261.             if (null !== $type) {
  262.                 $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  263.             }
  264.  
  265.             $line = $prefix.$line;
  266.             $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  267.  
  268.             if ($style) {
  269.                 $line = sprintf('<%s>%s</>', $style, $line);
  270.             }
  271.         }
  272.  
  273.         return $lines;
  274.     }
  275. }
  276.  
  277.    Symfony\Component\Debug\Exception\FatalThrowableError  : Class 'Symfony\Component\Console\Style\SymfonyStyle' not found
  278.  
  279.   at C:\xampp\htdocs\cvtheque\vendor\laravel\framework\src\Illuminate\Console\OutputStyle.php:9
  280.      5| use Symfony\Component\Console\Style\SymfonyStyle;
  281.      6| use Symfony\Component\Console\Input\InputInterface;
  282.      7| use Symfony\Component\Console\Output\OutputInterface;
  283.      8|
  284.   >  9| class OutputStyle extends SymfonyStyle
  285.     10| {
  286.     11|     /**
  287.     12|      * The output instance.
  288.     13|      *
  289.  
  290.   Exception trace:
  291.  
  292.   1   include()
  293.       C:\xampp\htdocs\cvtheque\vendor\composer\ClassLoader.php:444
  294.  
  295.   2   Composer\Autoload\includeFile("C:\xampp\htdocs\cvtheque\vendor\composer/../laravel/framework/src/Illuminate/Console/OutputStyle.php")
  296.       C:\xampp\htdocs\cvtheque\vendor\composer\ClassLoader.php:322
  297.  
  298.   Please use the argument -v to see more details.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top