The wrapper for creating shell instances.

@param string $className Shell class name.
@param \Cake\Console\ConsoleIo $io The IO wrapper for the created shell class.
@return \Cake\Console\Shell|\Cake\Console\Command
980
protected function createShell($className, ConsoleIo $io)
    {
        $shell = $this->factory->create($className);
        if ($shell instanceof Shell) {
            $shell->setIo($io);
        }

        return $shell;
    }
558754
public function create(string $className)
    {
        $this->console->writeLine('Please enter the script name for the console app: ');
        $stubFileName = $this->rootpath->to('bin',  $this->console->readLine());
        if (!file_exists($stubFileName)) {
            $this->createFile($stubFileName, $className, 'script.tmpl');
            $this->console->writeLine(
                    'Script for ' . $className . ' created at ' . $stubFileName
            );
        } else {
            $this->console->writeLine(
                    'Script for ' . $className
                    . ' already exists, skipped creating the script'
            );
        }
    }
471179
protected static function buildComponent(string $className)
    {
        if (!isset(self::$components[$className])) {
            self::$components[$className] = Container::buildObject("\\Osf\\View\\Component\\" . $className);
            if (!(self::$components[$className] instanceof Component\AbstractComponent)) {
                throw new ArchException('Component [' . $className . '] must be an AbstractComponent');
            }
        }
        return self::$components[$className];
    }
1257117
public function execute(Arguments $args, ConsoleIo $io)
    {
        $file = Folder::slashTerm(WWW_ROOT) . 'vendor' . DS . 'kcfinder' . DS . '.htaccess';

        if ($this->verboseIfFileExists($io, $file)) {
        } elseif ((new KCFinder)->isAvailable()) {
            $io->createFile(
                Folder::slashTerm(WWW_ROOT) . 'vendor' . DS . 'kcfinder' . DS . '.htaccess',
                'php_value session.cache_limiter must-revalidate' . PHP_EOL .
                'php_value session.cookie_httponly On' . PHP_EOL .
                'php_value session.cookie_lifetime 14400' . PHP_EOL .
                'php_value session.gc_maxlifetime 14400' . PHP_EOL .
                'php_value session.name CAKEPHP'
            );
        } else {
            $io->error(__d('me_tools', '{0} is not available', 'KCFinder'));
        }

        return null;
    }
571938
public function execute(Arguments $args, ConsoleIo $io)
    {
        if (!$args->getOption('xml')) {
            $io->out('<info>Current Paths:</info>', 2);
            $io->out('* app:  ' . APP_DIR . DIRECTORY_SEPARATOR);
            $io->out('* root: ' . ROOT . DIRECTORY_SEPARATOR);
            $io->out('* core: ' . CORE_PATH);
            $io->out('');

            $io->out('<info>Available Commands:</info>', 2);
        }

        $commands = $this->commands->getIterator();
        $commands->ksort();

        if ($args->getOption('xml')) {
            $this->asXml($io, $commands);

            return static::CODE_SUCCESS;
        }
        $this->asText($io, $commands);

        return static::CODE_SUCCESS;
    }
576231
public function create(string $className, string $typeName): Type
    {
        $type = clone $this->types->getInput($className);
        $fieldsGetter = $type->config['fields'];

        $optionalFieldsGetter = function () use ($fieldsGetter): array {
            $optionalFields = [];
            foreach ($fieldsGetter() as $field) {
                if ($field['type'] instanceof NonNull) {
                    $field['type'] = $field['type']->getWrappedType();
                }

                unset($field['defaultValue']);

                $optionalFields[] = $field;
            }

            return $optionalFields;
        };
        $type->config['fields'] = $optionalFieldsGetter;
        $type->name = $typeName;

        return $type;
    }
555228
public function EXE(I_O $IO)
    {
        return $IO->_O(
            $IO->I_(Type::BOOL) xor
            $IO->I_(Type::BOOL)
        );
    }
387170
public function execute(Arguments $args, ConsoleIo $io)
    {
        foreach ($this->config as $file) {
            list($plugin, $file) = pluginSplit($file);
            $this->copyFile(
                $io,
                Plugin::path($plugin, 'config' . DS . $file . '.php'),
                Folder::slashTerm(CONFIG) . $file . '.php'
            );
        }

        return null;
    }
597331
public function build(string $className): interfaces\commands\Command
    {
        $params = is_subclass_of($className, interfaces\commands\ExecutableCommand::class) ? [$this->bus] : [];

        /** @var interfaces\commands\Command $command */
        $command = \Yii::createObject($className, $params);

        $this->prepareCommand($command);

        return $command;
    }
1194860
public function singleton($className) {
        $closure = function(ContainerInterface $container) use($className) {
            static $instance;
            
            if (is_null($instance)) {
                $instance = $container->make($className);
            }

            return $instance;
        };

        $this->bind($className, $closure);
    }
677052
protected function setIO(InputInterface $input, OutputInterface $output)
    {
        $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
    }
1161447
public static function configure(IOInterface $io, PhpUnitStrictCoverage $strictCoverage)
    {
        if (true === $strictCoverage->isUndefined()) {
            $strictCoverageAnswer = $io->ask(
                HookQuestions::PHPUNIT_STRICT_COVERAGE,
                HookQuestions::DEFAULT_TOOL_ANSWER
            );

            $strictCoverage = $strictCoverage->setEnabled(
                new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($strictCoverageAnswer))
            );

            /** @var PhpUnitStrictCoverage $strictCoverage */
            if (true === $strictCoverage->isEnabled()) {
                $minimum = $io->ask(HookQuestions::PHPUNIT_STRICT_COVERAGE_MINIMUM, 0.00);
                $strictCoverage = $strictCoverage->setStrictCoverage(new MinimumStrictCoverage((float) $minimum));
            }
        }

        return $strictCoverage;
    }
1214511
public function createLink(ConsoleIo $io, $source, $dest)
    {
        if ($this->verboseIfFileExists($io, $dest)) {
            return false;
        }

        //Checks if the source is readable and the destination directory is writable
        try {
            is_readable_or_fail($source);
            is_writable_or_fail(dirname($dest));
        } catch (Exception $e) {
            $io->error($e->getMessage());

            return false;
        }

        symlink($source, $dest);
        $io->verbose(__d('me_tools', 'Link `{0}` has been created', rtr($dest)));

        return true;
    }
530108
public function create(string $className)
    {
        if (!class_exists($className)) {
            $classFileName = $this->fileNameforClass($className);
            $this->createFile($classFileName, $className, 'class.tmpl');
            $this->console->writeLine(
                    'Class ' . $className . ' created at ' . $classFileName
            );
        } else {
            $this->console->writeLine(
                    'Class ' . $className
                    . ' already exists, skipped creating the class'
            );
        }
    }
564822
public static function configure(IOInterface $io, PhpCs $phpCs)
    {
        if (true === $phpCs->isUndefined()) {
            $answer = $io->ask(HookQuestions::PHPCS_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
            $phpCs = $phpCs->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));

            if (true === $phpCs->isEnabled()) {
                $standardAnswer = $io->ask(HookQuestions::PHPCS_STANDARD, null);
                /** @var PhpCs $phpCs */
                $phpCs = $phpCs->addStandard(new PhpCsStandard($standardAnswer));

                $ignoreOptionAnswer = $io->ask(HookQuestions::PHPCS_IGNORE, null);
                $phpCs->addIgnore(new Ignore($ignoreOptionAnswer));
            }
        }

        return $phpCs;
    }
836748
public function run(array $argv, ConsoleIo $io)
    {
        $this->initialize();

        $parser = $this->getOptionParser();
        try {
            list($options, $arguments) = $parser->parse($argv);
            $args = new Arguments(
                $arguments,
                $options,
                $parser->argumentNames()
            );
        } catch (ConsoleException $e) {
            $io->err('Error: ' . $e->getMessage());

            return static::CODE_ERROR;
        }
        $this->setOutputLevel($args, $io);

        if ($args->getOption('help')) {
            $this->displayHelp($parser, $args, $io);

            return static::CODE_SUCCESS;
        }

        return $this->execute($args, $io);
    }
520006
public static function createNewObject($className, $args = null)
    {
        $mock = self::getMock(self::$injectedObjects, 'object', $className);
        if ($mock !== null)
        {
            return $mock;
        }

        if ($args === null)
        {
            return new $className();
        }

        // we need to pass arguments which requires reflection
        $reflection = new ReflectionClass($className);
        return $reflection->newInstanceArgs($args);
    }