@param \Symfony\Component\Console\Input\InputInterface   $input
@param \Symfony\Component\Console\Output\OutputInterface $output

@return int

@throws \Spatie\Php7to5\Exceptions\InvalidParameter
178770
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln("<info>Start converting {$input->getArgument('source')}</info>");

        $source = $input->getArgument('source');

        if (!file_exists($source)) {
            throw InvalidParameter::sourceDoesNotExist($source);
        }

        if (is_file($source)) {
            $this->convertFile($input);
        }
        if (is_dir($source)) {
            $this->convertPHPFilesInDirectory($input, $output);
        }
        $output->writeln('<info>All done!</info>');

        return 0;
    }
543964
public function doRun(InputInterface $input, OutputInterface $output) : int
    {
        $output->setDecorated(false);
        $input->setInteractive(false);

        $command = $this->createCommand();
        return $command->run($input, $output);
    }
458761
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->setOutput($output);
        $this->setVerbosity($output->getVerbosity());

        if (!$input->getOption('add') && !$input->getOption('delete') && !$input->getOption('skip') && !$input->getOption('info')) {
            throw new \InvalidArgumentException('You must specify whether you want to --add, --delete, --skip or --info the specified migration.');
        }

        $migrationService = $this->getMigrationService();
        $migrationNameOrPath = $input->getArgument('migration');

        if ($input->getOption('info')) {
            $output->writeln('');

            $migration = $migrationService->getMigration($migrationNameOrPath);
            if ($migration == null) {
                throw new \InvalidArgumentException(sprintf('The migration "%s" does not exist in the migrations table.', $migrationNameOrPath));
            }

            switch ($migration->status) {
                case Migration::STATUS_DONE:
                    $status = '<info>executed</info>';
                    break;
                case Migration::STATUS_STARTED:
                    $status = '<comment>execution started</comment>';
                    break;
                case Migration::STATUS_TODO:
                    // bold to-migrate!
                    $status = '<error>not executed</error>';
                    break;
                case Migration::STATUS_SKIPPED:
                    $status = '<comment>skipped</comment>';
                    break;
                case Migration::STATUS_PARTIALLY_DONE:
                    $status = '<comment>partially executed</comment>';
                    break;
                case Migration::STATUS_SUSPENDED:
                    $status = '<comment>suspended</comment>';
                    break;
                case Migration::STATUS_FAILED:
                    $status = '<error>failed</error>';
                    break;
            }

            $output->writeln('<info>Migration: ' . $migration->name . '</info>');
            $output->writeln('Status: ' . $status);
            $output->writeln('Executed on: <info>' . ($migration->executionDate != null ? date("Y-m-d H:i:s", $migration->executionDate) : '--'). '</info>');
            $output->writeln('Execution notes: <info>' . $migration->executionError . '</info>');

            if ($migration->status == Migration::STATUS_SUSPENDED) {
                /// @todo decode the suspension context: date, step, ...
            }

            $output->writeln('Definition path: <info>' . $migration->path . '</info>');
            $output->writeln('Definition md5: <info>' . $migration->md5 . '</info>');

            if ($migration->path != '') {
                // q: what if we have a loader which does not work with is_file? We could probably remove this check...
                if (is_file($migration->path)) {
                    try {
                        $migrationDefinitionCollection = $migrationService->getMigrationsDefinitions(array($migration->path));
                        if (count($migrationDefinitionCollection)) {
                            $migrationDefinition = reset($migrationDefinitionCollection);
                            $migrationDefinition = $migrationService->parseMigrationDefinition($migrationDefinition);

                            if ($migrationDefinition->status != MigrationDefinition::STATUS_PARSED) {
                                $output->writeln('Definition error: <error>' . $migrationDefinition->parsingError . '</error>');
                            }

                            if (md5($migrationDefinition->rawDefinition) != $migration->md5) {
                                $output->writeln('Notes: <comment>The migration definition file has now a different checksum</comment>');
                            }
                        } else {
                            $output->writeln('Definition error: <error>The migration definition file can not be loaded</error>');
                        }
                    } catch (\Exception $e) {
                        /// @todo one day we should be able to limit the kind of exceptions we have to catch here...
                        $output->writeln('Definition parsing error: <error>' . $e->getMessage() . '</error>');
                    }
                } else {
                    $output->writeln('Definition error: <error>The migration definition file can not be found any more</error>');
                }
            }

            $output->writeln('');
            return 0;
        }

        // ask user for confirmation to make changes
        if ($input->isInteractive() && !$input->getOption('no-interaction')) {
            $dialog = $this->getHelperSet()->get('question');
            if (!$dialog->ask(
                $input,
                $output,
                new ConfirmationQuestion('<question>Careful, the database will be modified. Do you want to continue Y/N ?</question>', false)
            )
            ) {
                $output->writeln('<error>Migration change cancelled!</error>');
                return 0;
            }
        }

        if ($input->getOption('add')) {
            // will throw if a file is passed and it is not found, but not if an empty dir is passed
            $migrationDefinitionCollection = $migrationService->getMigrationsDefinitions(array($migrationNameOrPath));

            if (!count($migrationDefinitionCollection))
            {
                throw new \InvalidArgumentException(sprintf('The path "%s" does not correspond to any migration definition.', $migrationNameOrPath));
            }

            foreach ($migrationDefinitionCollection as $migrationDefinition) {
                $migrationName = basename($migrationDefinition->path);

                $migration = $migrationService->getMigration($migrationNameOrPath);
                if ($migration != null) {
                    throw new \InvalidArgumentException(sprintf('The migration "%s" does already exist in the migrations table.', $migrationName));
                }

                $migrationService->addMigration($migrationDefinition);
                $output->writeln('<info>Added migration' . $migrationDefinition->path . '</info>');
            }

            return 0;
        }

        if ($input->getOption('delete')) {
            $migration = $migrationService->getMigration($migrationNameOrPath);
            if ($migration == null) {
                throw new \InvalidArgumentException(sprintf('The migration "%s" does not exist in the migrations table.', $migrationNameOrPath));
            }

            $migrationService->deleteMigration($migration);

            return 0;
        }

        if ($input->getOption('skip')) {
            // will throw if a file is passed and it is not found, but not if an empty dir is passed
            $migrationDefinitionCollection = $migrationService->getMigrationsDefinitions(array($migrationNameOrPath));

            if (!count($migrationDefinitionCollection))
            {
                throw new \InvalidArgumentException(sprintf('The path "%s" does not correspond to any migration definition.', $migrationNameOrPath));
            }

            foreach ($migrationDefinitionCollection as $migrationDefinition) {
                $migrationService->skipMigration($migrationDefinition);
                $output->writeln('<info>Migration' . $migrationDefinition->path . ' marked as skipped</info>');
            }

            return 0;
        }

        throw new \InvalidArgumentException("Please specify one action to be taken on the given migration");
    }
221302
protected function initialize(InputInterface $input, OutputInterface $output)
    {

        parent::initialize($input, $output);

        $translationMode = $input->getOption('mode');
        $validModes      = array(
            'reviewed',
            'translated',
            'default'
        );
        if (!in_array($translationMode, $validModes)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Invalid translation mode %s specified. Must be one of %s',
                    $translationMode,
                    implode(', ', $validModes)
                )
            );
        }
    }
1176625
public function execute(InputInterface $input, OutputInterface $output)
    {
        if (($destPath = $input->getOption('dest-path')) === null) {
            $destPath = 'config';
        }

        if (($author = $input->getArgument('author')) === null) {
            throw new InvalidArgumentException('Missing author option');
        }

        if (($sourceFilePath = $input->getOption('source-file')) === null) {
            $sourceFilePath = 'config/doctrine.php';
        }

        $destPath = realpath($destPath);

        if (!is_dir($destPath)) {
            mkdir($destPath, 0777, true);
        }

        if (!is_writable($destPath)) {
            throw new InvalidArgumentException(
                sprintf("Configuration destination directory '<info>%s</info>' does not have write permissions.",
                    $destPath)
            );
        }

        $destFilePath = $destPath . '/doctrine.generated.php';

        $originalSourceFilePath = $sourceFilePath;
        $sourceFilePath         = realPath($sourceFilePath);

        if (!file_exists($sourceFilePath)) {
            throw new InvalidArgumentException(
                sprintf("Source file at path '<info>%s</info>' does not exist.",
                    $originalSourceFilePath)
            );
        }

        $sourceArrayConfig = include $sourceFilePath;

        $viewFactory = $this->createViewFactory();

        $className = __NAMESPACE__ . '\ConfigMigrations\\' . ucfirst($author) . 'Migrator';

        if (!class_exists($className)) {
            throw new InvalidArgumentException('Author provided was not a valid choice.');
        } else {
            $configMigrator        = new $className($viewFactory);
            $convertedConfigString = $configMigrator->convertConfiguration($sourceArrayConfig);
        }

        file_put_contents($destFilePath, '<?php ' . $convertedConfigString);

        $output->writeln('Conversion successful. File generated at ' . $destFilePath);
    }
234391
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $pipeLine = $this->pipeline;
        $pipeLine($input->getOptions());

        return 0;
    }
364282
protected function init(InputInterface $input, OutputInterface $output)
    {
    	$this->input = $input;
    	$this->output = $output;

    	$this->bbapp = $this->getApplication()->getApplication();
    	$this->entyMgr = $this->bbapp->getEntityManager();

    	$this->siteLabel = $this->input->getOption('site_label');

        if (filter_var($this->input->getOption('site_domain'), FILTER_VALIDATE_URL)) {
            $urlData = parse_url($this->input->getOption('site_domain'));

            if(!empty($urlData['host']) && $urlData['host'] !== null) {
                $this->siteDomain = $urlData['host'].(empty($urlData['port']) ? '' : ':'.$urlData['port']).(empty($urlData['path']) ? '' : $urlData['path']);
            }
        } else {
            throw new \InvalidArgumentException('Invalid site domain format. Example of valid domain: http://backbee.com');
        }

    	return $this;
    }
1365028
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        // Throw an exception immediately if we don't have the required DB parameter
        if (empty($input->getOption('db'))) {
            throw new \InvalidArgumentException('Database name is required (--db)');
        }

        $password = $input->getOption('password');
        if (null === $password) {
            $question = new Question('Password: ');
            $question->setHidden(true)->setHiddenFallback(false);

            $password = $this->getHelper('question')->ask($input, $output, $question);
        }

        $ignoreFields = $input->getOption('ignore-field');


        $this->dbUtils->configure([
            'driver' => $input->getOption('driver'),
            'host' => $input->getOption('host'),
            'dbname' => $input->getOption('db'),
            'user' => $input->getOption('user'),
            'password' => $password,
        ]);

        $writer = new \Edyan\Neuralyzer\Configuration\Writer;
        $writer->protectCols($input->getOption('protect'));

        // Override the protection if fields are defined
        if (!empty($ignoreFields)) {
            $writer->protectCols(true);
            $writer->setProtectedCols($ignoreFields);
        }

        $writer->setIgnoredTables($input->getOption('ignore-table'));
        $data = $writer->generateConfFromDB($this->dbUtils, new \Edyan\Neuralyzer\Guesser);
        $writer->save($data, $input->getOption('file'));

        $output->writeln('<comment>Configuration written to '.$input->getOption('file').'</comment>');
    }
665599
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $userService = new UserService($this->userStore);

        /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
        $dialog = $this->getHelperSet()->get('dialog');

        // Function to validate mail address.
        $mailValidator = function ($answer) {
            if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
                throw new \InvalidArgumentException(Lang::get('must_be_valid_email'));
            }

            return $answer;
        };

        $adminEmail = $dialog->askAndValidate($output, Lang::get('enter_email'), $mailValidator, false);
        $adminName = $dialog->ask($output, Lang::get('enter_name'));
        $adminPass = $dialog->askHiddenResponse($output, Lang::get('enter_password'));

        try {
            $userService->createUser($adminName, $adminEmail, $adminPass, true);
            $output->writeln(Lang::get('user_created'));
        } catch (\Exception $e) {
            $output->writeln(sprintf('<error>%s</error>', Lang::get('failed_to_create')));
            $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
        }
    }
260941
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
        $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        $errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);

        $batchSize = NumberUtils::bound($input->getOption('batch-size'), 1, 1000);
        $batchDelay = NumberUtils::bound($input->getOption('batch-delay'), 100, 600000);
        $since = $input->getOption('since');
        $until = $input->getOption('until');
        $context = json_decode($input->getOption('context') ?: '{}', true);
        $context['tenant_id'] = (string)$input->getOption('tenant-id');
        $streamId = $input->getArgument('stream-id') ? StreamId::fromString($input->getArgument('stream-id')) : null;

        if (!empty($since)) {
            $since = Microtime::fromString(str_pad($since, 16, '0'));
        }

        if (!empty($until)) {
            $until = Microtime::fromString(str_pad($until, 16, '0'));
        }

        $i = 0;
        $receiver = function (Event $event, StreamId $streamId) use ($errOutput, $batchSize, $batchDelay, &$i) {
            ++$i;

            try {
                echo json_encode($event) . PHP_EOL;
            } catch (\Throwable $e) {
                $errOutput->writeln($e->getMessage());
            }

            if (0 === $i % $batchSize) {
                if ($batchDelay > 0) {
                    usleep($batchDelay * 1000);
                }
            }
        };

        if ($streamId) {
            $this->getPbjx()->getEventStore()->pipeEvents($streamId, $receiver, $since, $until, $context);
        } else {
            $this->getPbjx()->getEventStore()->pipeAllEvents($receiver, $since, $until, $context);
        }
    }
526874
protected function execute(InputInterface $input, OutputInterface $output) : int
    {
        $queue = self::queue($input->getOption('queue'));

        $json = json_decode($input->getArgument('args'), true);
        if (json_last_error() !== 0) {
            throw new UserException(sprintf("Invalid json for args with error '%s'", json_last_error_msg()));
        }

        if (stripos($input->getArgument('class'), '\\\\') !== false) {
            throw new UserException(sprintf("Invalid class name '%s'", $input->getArgument('class')));
        }

        $job = new Job($input->getArgument('class'), $json);

        $queue->publish($job->serialize());

        return 0;
    }
306872
protected function execute(InputInterface $input, OutputInterface $output)
    {
        //  validate the content types unless validation is ignored

        if ($input->getArgument('id') && !$input->getOption('ignore')) {
            $code = $this->executeValidation($input, $output);

            if ($code) {
                return $code;
            }
        }

        if ($input->getOption('delete')) {
            return $this->executeDelete($input, $output);
        }

        if (!$input->getArgument('id') && !$input->getOption('full')) {
            throw new InvalidArgumentException(
                'You need to give one or more content types or choose the --full or --delete option'
            );
        }

        return $this->executeIndex($input, $output);
    }
1230607
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $sourceArg = realpath($input->getArgument('source'));
        $ruleSetArg = realpath($input->getArgument('ruleset'));

        if (false === $sourceArg || false === $ruleSetArg) {
            throw new \InvalidArgumentException(
                sprintf(
                    '%s argument is invalid: "%s" is not a path.',
                    $sourceArg ? 'Rule set' : 'Source directory',
                    $sourceArg ? $input->getArgument('ruleset') : $input->getArgument('source')
                )
            );
        }

        $config = new Configuration(
            $input->getArgument('ruleset'),
            $input->getOption('container-cache'),
            $input->getOption('no-cache'),
            $input->getOption('cache-dir'),
            $input->getOption('filter-methods'),
            $input->getOption('fail'),
            $input->getOption('verbose'),
            $input->getOption('log-html'),
            $input->getOption('output')
        );

        $factory = new DetectorFactory();
        $detector = $factory->create($config, $output);
        $violations = $detector->checkForDeprecations($sourceArg, $ruleSetArg);

        if ($config->failOnDeprecation() && !empty($violations)) {
            return 1;
        }

        return 0;
    }
385215
protected function execute(InputInterface $input, OutputInterface $output) : int
    {
        $io         = $this->getIO($input, $output);
        $config     = $this->getConfig($this->configFile, true);
        $repository = new Repository($this->repositoryPath);
        $arguments  = new Config\Options($input->getArguments());

        /** @var \CaptainHook\App\Runner\Hook $hook */
        $class = '\\CaptainHook\\App\\Runner\\Hook\\' . Util::getHookCommand($this->name);
        $hook  = new $class($io, $config, $repository, $arguments);


        $hook->run();
        return 0;
    }
11912
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $builder = $this->getMenuBuilder($input, $output);
        if ($input->getOption('dump')) {
            $this->dumpCommands($builder, $output);
        } else {
            $builder->build()->open();
        }
        return 0;
    }
1075548
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->injectOutputIntoLogger($output, $this->logger);
        $adapter = $this->shellAdapterManager->getAdapter($input->getOption('adapter'));
        if ($adapter instanceof LoggerAwareInterface) {
            $adapter->setLogger($this->logger);
        }

        $environmentVariables = [];
        if ($input->getOption('env')) {
            foreach ($input->getOption('env') as $value) {
                if (false === strpos($value, '=')) {
                    throw new Exception\InvalidArgumentException(
                        'Environment variables must be specified in the format --env myvar1=myval1 --env myvar2=myval2.'
                    );
                }
                [$key, $value] = explode('=', $value);
                $environmentVariables[$key] = $value;
            }
        }

        $output->write(
            $adapter->runShellCommand(
                $input->getArgument('cmd'),
                $input->getOption('working-directory'),
                $environmentVariables,
                $input->getOption('priority')
            )
        );
        return 0;
    }
946925
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
        $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        $errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);

        $context = json_decode($input->getOption('context') ?: '{}', true);
        $context['tenant_id'] = (string)$input->getOption('tenant-id');

        $nodeRef = NodeRef::fromString($input->getArgument('node-ref'));
        $consistent = $input->getOption('consistent') ? true : false;

        try {
            $node = $this->ncr->getNode($nodeRef, $consistent, $context);
            echo json_encode($node, $input->getOption('pretty') ? JSON_PRETTY_PRINT : 0) . PHP_EOL;
        } catch (\Throwable $e) {
            $errOutput->writeln($e->getMessage());
        }
    }