Enable the deprecated no progress bar option.

@param InputInterface $input The input.

@return void

@deprecated This is deprecated since 1.4 and where removed in 2.0. Use the option no-progress instead.
485994
private function enableDeprecatedNoProgressBar(InputInterface $input)
    {
        if (!$input->getOption('no-progress-bar')) {
            return;
        }

        // @codingStandardsIgnoreStart
        @trigger_error(
            'The command option --no-progress-bar is deprecated since 1.4 and where removed in 2.0.
             Use --no-progress instead.',
            E_USER_DEPRECATED
        );
        // @codingStandardsIgnoreEnd

        $input->setOption('no-progress', true);
    }
49316
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $input->getOption('path');
        $failOnly = $input->getOption('fail-only');
        $format = $input->getOption('format');
        $context = $input->getOption('context');
        $threshold = $input->getOption('threshold');
        $version = $input->getOption('php');
        $outputPath = $input->getOption('output');

        if ($format === 'html' && $outputPath === null) {
            throw new \InvalidArgumentException('Output path must be set for format "HTML"');
        }

        $context = ($context !== null)
            ? explode(', ', $context) : array();

        // If we're not given a version, assume the current version
        if ($version === null) {
            $version = PHP_VERSION;
        }

        // if we're not given a path at all, try to figure it out
        if ($path === null) {
            $path = php_ini_loaded_file();
        }

        if (!is_file($path)) {
            throw new \Exception('Path is null or not accessible: "'.$path.'"');
        }

        $scan = new \Psecio\Iniscan\Scan($path, $context, $threshold, $version);
        $results = $scan->execute();
        $deprecated = $scan->getMarked();

        $options = array(
            'path' => $path,
            'failOnly' => $failOnly,
            'deprecated' => $deprecated,
            'verbose' => $input->getOption('verbose'),
            'output' => $outputPath
        );

        $format = ($format === null) ? 'console' : $format;
        $formatClass = "\\Psecio\\Iniscan\\Command\\ScanCommand\\Output\\".ucwords(strtolower($format));
        if (!class_exists($formatClass)) {
            throw new \Psecio\Iniscan\Exceptions\FormatNotFoundException('Output format "'.$format.'" not found');
        }
        $outputHandler = new $formatClass($output, $options);
        return $outputHandler->render($results);
    }
968781
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $dryRun = $input->getOption('dry-run');
        $skipInvalid = $input->getOption('skip-invalid');
        $skipErrors = $input->getOption('skip-errors');
        $batchSize = NumberUtils::bound($input->getOption('batch-size'), 1, 5000);
        $batchDelay = NumberUtils::bound($input->getOption('batch-delay'), 100, 600000);
        $startLine = $input->getOption('start-line');
        $endLine = $input->getOption('end-line');
        $file = $input->getArgument('file');

        $io = new SymfonyStyle($input, $output);
        $io->title(sprintf('Reading messages from "%s"', $file));
        $this->useInMemoryTransports($input, $io);
        if (!$this->readyForPbjxTraffic($io, 'Aborting json lines processing.')) {
            return;
        }

        if (!file_exists($file) || !is_readable($file)) {
            $io->error(sprintf('File "%s" must exist and be readable.', $file));
            return;
        }

        /*
         * Pbjx processes are somewhat origination agnostic so we'll just make their
         * environments seem similar
         */
        $_SERVER['REQUEST_METHOD'] = 'POST';
        $_SERVER['CONTENT_TYPE'] = 'application/json';
        $_SERVER['HTTP_ACCEPT'] = 'application/json';
        $_SERVER['HTTP_ACCEPT_CHARSET'] = 'utf-8';
        $_SERVER['HTTP_USER_AGENT'] = $input->getOption('user-agent') ?: 'pbjx-console/0.x';

        $deviceView = $input->getOption('device-view');
        if (!empty($deviceView)) {
            $_SERVER['DEVICE_VIEW'] = $deviceView;
            putenv('DEVICE_VIEW=' . $deviceView);
        }

        $handle = @fopen($file, 'r');
        if (!$handle) {
            $io->error(sprintf('Unable to open file "%s".', $file));
            return;
        }

        $requestStack = $this->getRequestStack();
        $pbjx = $this->getPbjx();
        $serializer = new JsonSerializer();
        $batch = 1;
        $i = 0;
        $processed = 0;
        $io->comment(sprintf('Processing batch %d from file "%s".', $batch, $file));
        $io->newLine();

        while (($line = fgets($handle)) !== false) {
            ++$i;

            $line = trim($line);
            if (empty($line)) {
                continue;
            }

            if ($i < $startLine) {
                continue;
            }

            if ($i > $endLine) {
                $io->note(sprintf('%d. End line reached, stopping process.', $endLine));
                break;
            }

            try {
                /** @var Command|Event $message */
                $message = $serializer->deserialize($line);
                $curie = $message::schema()->getCurie();
                $ref = $message->generateMessageRef()->toString();

                $request = Request::create(
                    sprintf(
                        '/pbjx/%s/%s/%s/%s',
                        $curie->getVendor(),
                        $curie->getPackage(),
                        $curie->getCategory() ?: '_',
                        $curie->getMessage()
                    ),
                    $_SERVER['REQUEST_METHOD'],
                    [], // GET and POST (aka $_REQUEST)
                    $_COOKIE,
                    $_FILES,
                    $_SERVER,
                    $line
                );

                /*
                 * prepare the request object so http and console processing are virtually the same
                 */
                $request->setRequestFormat('json');
                $request->attributes->set('pbjx_vendor', $curie->getVendor());
                $request->attributes->set('pbjx_package', $curie->getPackage());
                $request->attributes->set('pbjx_category', $curie->getCategory());
                $request->attributes->set('pbjx_message', $curie->getMessage());
                $request->attributes->set('pbjx_bind_unrestricted', true);
                $request->attributes->set('pbjx_console', true);
                if (!empty($deviceView)) {
                    $request->attributes->set('device_view', $deviceView);
                }

                $requestStack->pop();
                $requestStack->push($request);
                ++$processed;

                if ($dryRun) {
                    $io->text(sprintf(
                        '<info>%d.</info> DRY RUN <comment>ref:</comment>%s, <comment>occurred_at:</comment>%s',
                        $i,
                        $ref,
                        $message->get('occurred_at')
                    ));
                } else {
                    if ($message instanceof Command) {
                        $io->text(sprintf(
                            '<info>%d.</info> Sending <comment>ref:</comment>%s, <comment>occurred_at:</comment>%s',
                            $i,
                            $ref,
                            $message->get('occurred_at')
                        ));
                        $pbjx->send($message);
                    } elseif ($message instanceof Event) {
                        $io->text(sprintf(
                            '<info>%d.</info> Publishing <comment>ref:</comment>%s, <comment>occurred_at:</comment>%s',
                            $i,
                            $ref,
                            $message->get('occurred_at')
                        ));
                        $pbjx->publish($message);
                    } else {
                        $io->warning(sprintf('%d. Ignoring "%s" since it\'s not a command or event.', $i, $ref));
                        --$processed;
                    }
                }
            } catch (DeserializeMessageFailed $de) {
                $io->error(sprintf('%d. %s', $i, $de->getMessage()));
                $io->note(sprintf('%d. Failed to deserialize json line below:', $i));
                $io->text($line);
                $io->newLine(2);
                if (!$skipInvalid) {
                    break;
                }
            } catch (\Throwable $e) {
                $io->error(sprintf('%d. %s', $i, $e->getMessage()));
                $io->newLine(2);
                if (!$skipErrors) {
                    break;
                }
            }

            if (0 === $i % $batchSize) {
                ++$batch;

                if ($batchDelay > 0) {
                    $io->newLine();
                    $io->note(sprintf('Pausing for %d milliseconds.', $batchDelay));
                    usleep($batchDelay * 1000);
                }

                $io->comment(sprintf('Processing batch %d from file "%s".', $batch, $file));
                $io->newLine();
            }
        }

        @fclose($handle);

        $io->newLine();
        $io->success(sprintf('Processed %s messages from "%s".', number_format($processed), $file));
    }
123531
protected function setIo(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $output;

        return $this;
    }
215072
public function setInput($input)
    {
        $this->input = ProcessUtils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $input);

        return $this;
    }
359638
protected function isDevelopmentModeEnabled(InputInterface $input)
    {
        if (false == $input->getOption('no-dev')) {
            return $input->getOption('dev') || PHP_DEBUG;
        }

        return false;
    }
1008807
protected function executeIndex(InputInterface $input, OutputInterface $output)
    {
        // Don't hydrate for performance reasons
        $builder = $this->getDocumentManager()->createQueryBuilder(Content::class);
        $builder->select('id', 'contentType', 'class')->hydrate(false);

        if ($input->getOption('full')) {
            $result = $builder->getQuery()->execute();

            // The entire site is going to be reindex so everything that is now in the queue
            // will be redone so just clear it so content is not double indexed.

            $this->getQueue()->clear();
        } else {
            $builder->field('contentType')->in($input->getArgument('id'));

            $result = $builder->getQuery()->execute();
        }

        if ($count = $result->count()) {
            $progress = $this->getProgress();

            $progress->setRedrawFrequency(min(max(floor($count / 250), 1), 100));
            $progress->setFormat(ProgressHelper::FORMAT_VERBOSE);

            $progress->start($output, $count);

            // get the current time as it will be required at the end for the solr clean up.

            $date = new DateTime();

            $this->doIndex($result, $progress);
            $this->doIndexCleanup($input->getArgument('id'), $date);
            $this->doIndexCommit();

            $progress->display();
            $progress->finish();
        } else {
            // No content was found but that does not mean nothing should be done. As the solr
            // index should reflect the database so delete all the content for the matching
            // content types out the solr index.

            $this->doIndexCleanup($input->getArgument('id'));
            $this->doIndexCommit();
        }

        $this->getDocumentManager()->clear();

        return 0;
    }
980225
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->setIO($input, $output);
        parent::doRun($input, $output);
    }
465431
public function doRun(InputInterface $input, OutputInterface $output)
    {
        if (true === $input->hasParameterOption(['--version', '-V'], true)) {
            $output->writeln($this->getLongVersion());

            return 0;
        }

        try {
            // Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument.
            $input->bind($this->getDefinition());
        } catch (ExceptionInterface $e) {
            // Errors must be ignored, full binding/validation happens later when the command is known.
        }

        $name = $this->getCommandName($input);
        if (true === $input->hasParameterOption(['--help', '-h'], true)) {
            if (!$name) {
                $name = 'help';
                $input = new ArrayInput(['command_name' => $this->defaultCommand]);
            } else {
                $this->wantHelps = true;
            }
        }

        if (!$name) {
            $name = $this->defaultCommand;
            $definition = $this->getDefinition();
            $definition->setArguments(array_merge(
                $definition->getArguments(),
                [
                    'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
                ]
            ));
        }

        try {
            $this->runningCommand = null;
            // the command name MUST be the first element of the input
            $command = $this->find($name);
        } catch (\Throwable $e) {
            if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
                if (null !== $this->dispatcher) {
                    $event = new ConsoleErrorEvent($input, $output, $e);
                    $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);

                    if (0 === $event->getExitCode()) {
                        return 0;
                    }

                    $e = $event->getError();
                }

                throw $e;
            }

            $alternative = $alternatives[0];

            $style = new SymfonyStyle($input, $output);
            $style->block(sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error');
            if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
                if (null !== $this->dispatcher) {
                    $event = new ConsoleErrorEvent($input, $output, $e);
                    $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);

                    return $event->getExitCode();
                }

                return 1;
            }

            $command = $this->find($alternative);
        }

        $this->runningCommand = $command;
        $exitCode = $this->doRunCommand($command, $input, $output);
        $this->runningCommand = null;

        return $exitCode;
    }
1198571
private function validateInput(InputInterface $input)
    {
        if (!$input->getArgument('target')) {
            // if no target is passed, there can be no properties or methods
            foreach (['properties', 'methods', 'no-inherit'] as $option) {
                if ($input->getOption($option)) {
                    throw new RuntimeException('--' . $option . ' does not make sense without a specified target');
                }
            }

            foreach (['globals', 'vars', 'constants', 'functions', 'classes', 'interfaces', 'traits'] as $option) {
                if ($input->getOption($option)) {
                    return;
                }
            }

            // default to --vars if no other options are passed
            $input->setOption('vars', true);
        } else {
            // if a target is passed, classes, functions, etc don't make sense
            foreach (['vars', 'globals', 'functions', 'classes', 'interfaces', 'traits'] as $option) {
                if ($input->getOption($option)) {
                    throw new RuntimeException('--' . $option . ' does not make sense with a specified target');
                }
            }

            foreach (['constants', 'properties', 'methods'] as $option) {
                if ($input->getOption($option)) {
                    return;
                }
            }

            // default to --constants --properties --methods if no other options are passed
            $input->setOption('constants',  true);
            $input->setOption('properties', true);
            $input->setOption('methods',    true);
        }
    }
959992
protected function setIblocks(InputInterface $input)
    {
        $iblocks = IblockTable::query()
            ->setFilter([
                'IBLOCK_TYPE_ID' => $input->getArgument('type'),
                'CODE' => $input->getArgument('code')
            ])
            ->setSelect(['ID', 'CODE'])
            ->exec();

        if ($iblocks->getSelectedRowsCount() <= 0) {
            $this->errors[] = 'Iblock(s) not found';
        }

        $this->iblocks = $iblocks->fetchAll();
    }
1225427
protected function execute(InputInterface $input, OutputInterface $output) : int
    {
        return !is_null($this->exitCode) ? $this->exitCode : 0;
    }
1363478
private function run(InputInterface $input)
    {
        /** @var ConfigurationDataResponse $configurationDataResponse */
        $configurationDataResponse = $this->queryBus->handle(new ConfigurationDataFinder());

        if (true === $configurationDataResponse->getCommitMsg()->isCommitMsg()) {
            $commitContent = $this->commitMessageFinder->find($input->getFirstArgument());

            $regularExpression = $configurationDataResponse->getCommitMsg()->getRegularExpression();
            $validMessage = $this->isValidCommitMessage($regularExpression, $commitContent);

            if (false === $validMessage) {
                throw new InvalidCommitMessageException(
                    sprintf(
                        'Invalid Commit message: commit message does not match regex %s !',
                        $regularExpression
                    )
                );
            }
        }
    }
1149482
protected function getProgressBar(InputInterface $input)
    {
        $progress = parent::getProgressBar($input);
        if (!$progress) {
            return null;
        }

        /** @var Dispatcher $eventDispatcher */
        $eventDispatcher = $this->getService('event_dispatcher');
        $eventDispatcher->addListener(
            'transformer.transformation.post',
            function () use ($progress) {
                $progress->advance();
            }
        );

        return $progress;
    }
49804
protected function execute(InputInterface $input, OutputInterface $output) : void
    {
        $io     = $this->getIO($input, $output);
        $config = $this->getConfig($input->getOption('configuration'), true);

        $editor = new Editor($io, $config);
        $editor->setHook((string) $input->getArgument('hook'))
               ->setChange('AddAction');

        $editor->run();
    }
779494
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $verbosity = PhpVersions::VERBOSITY_NORMAL;
        $verbosity = $input->getOption('verbose') == 2 ? PhpVersions::VERBOSITY_VERBOSE : $verbosity;
        $verbosity = $input->getOption('verbose') == 3 ? PhpVersions::VERBOSITY_DEBUG : $verbosity;
        $verbosity = $input->getOption('quiet') ? PhpVersions::VERBOSITY_SILENT : $verbosity;
        $phpVersions = new PhpVersions(null, $verbosity);

        $versions = $input->getArgument('php');
        $version = array_shift($versions);
        if (empty($version)) {
            $version = 'latest';
        }

        $gpgKeys = [];
        foreach ($phpVersions->getGpgInfo($version) as $key)
        {
            $gpgKeys[] = str_replace(' ', '', $key['pub']);
        }

        $output->write(implode(' ', $gpgKeys));
    }
219178
protected function shouldWait(InputInterface $input)
    {
        if ($input->hasOption('no-wait') && $input->getOption('no-wait')) {
            return false;
        }
        if ($input->hasOption('wait') && $input->getOption('wait')) {
            return true;
        }
        if ($this->detectRunningInHook()) {
            $serviceName = $this->config()->get('service.name');
            $message = "\n<comment>Warning:</comment> $serviceName hook environment detected: assuming <comment>--no-wait</comment> by default."
                . "\nTo avoid ambiguity, please specify either --no-wait or --wait."
                . "\n";
            $this->stdErr->writeln($message);

            return false;
        }

        return true;
    }