本文整理汇总了PHP中Composer\IO\IOInterface::ask方法的典型用法代码示例。如果您正苦于以下问题:PHP IOInterface::ask方法的具体用法?PHP IOInterface::ask怎么用?PHP IOInterface::ask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\IO\IOInterface
的用法示例。
在下文中一共展示了IOInterface::ask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
/**
* @param IOInterface $io
* @param CommitMsg $commitMsg
*
* @return CommitMsg
*/
public static function configure(IOInterface $io, CommitMsg $commitMsg)
{
$answer = $io->ask(HookQuestions::COMMIT_MSG_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER);
$commitMsg = $commitMsg->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
if (true === $commitMsg->isEnabled()) {
$regularExpressionAnswer = $io->ask(HookQuestions::COMMIT_MSG_REGULAR_EXPRESSION, HookQuestions::COMMIT_MSG_REGULAR_EXPRESSION_ANSWER);
$commitMsg = $commitMsg->addRegularExpression(new RegularExpression($regularExpressionAnswer));
}
return $commitMsg;
}
示例2: configure
/**
* @param IOInterface $io
* @param PhpMd $phpMd
*
* @return PhpMd
*/
public static function configure(IOInterface $io, PhpMd $phpMd)
{
if (true === $phpMd->isUndefined()) {
$answer = $io->ask(HookQuestions::PHPMD_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
$phpMd = $phpMd->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
$optionsAnswer = $io->ask(HookQuestions::PHPMD_OPTIONS, null);
$options = new PhpMdOptions($optionsAnswer);
$phpMd = $phpMd->setOptions($options);
}
return $phpMd;
}
示例3: configure
public static function configure(IOInterface $input, PrePush $prePush)
{
$answer = $input->ask(HookQuestions::PRE_PUSH_HOOK_QUESTION, HookQuestions::DEFAULT_TOOL_ANSWER);
$prePush = $prePush->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
if (true === $prePush->isEnabled()) {
$rightMessageAnswer = $input->ask(HookQuestions::PRE_PUSH_RIGHT_MESSAGE, HookQuestions::PRE_PUSH_RIGHT_MESSAGE_DEFAULT);
$errorMessageAnswer = $input->ask(HookQuestions::PRE_PUSH_ERROR_MESSAGE, HookQuestions::PRE_PUSH_ERROR_MESSAGE_DEFAULT);
$prePush = $prePush->setMessages(new Messages(new Message($rightMessageAnswer), new Message($errorMessageAnswer)));
}
return $prePush;
}
示例4: configure
/**
* @param IOInterface $io
* @param PreCommit $preCommit
*
* @return PreCommit
*/
public static function configure(IOInterface $io, PreCommit $preCommit)
{
$answer = $io->ask(HookQuestions::PRE_COMMIT_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER);
$preCommit = $preCommit->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
if (true === $preCommit->isEnabled()) {
$rightMessageAnswer = $io->ask(HookQuestions::PRE_COMMIT_RIGHT_MESSAGE, HookQuestions::PRE_COMMIT_RIGHT_MESSAGE_DEFAULT);
$errorMessageAnswer = $io->ask(HookQuestions::PRE_COMMIT_ERROR_MESSAGE, HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT);
$preCommit = $preCommit->setMessages(new Messages(new Message($rightMessageAnswer), new Message($errorMessageAnswer)));
}
return $preCommit;
}
示例5: configure
/**
* @param IOInterface $io
* @param PhpUnitStrictCoverage $strictCoverage
*
* @return PhpUnitStrictCoverage
*/
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.0);
$strictCoverage = $strictCoverage->setStrictCoverage(new MinimumStrictCoverage((double) $minimum));
}
}
return $strictCoverage;
}
示例6: configure
/**
* @param IOInterface $io
* @param PhpCs $phpCs
*
* @return PhpCs|\Module\Configuration\Model\ToolInterface
*/
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));
}
}
return $phpCs;
}
示例7: configure
/**
* @param IOInterface $input
* @param PhpUnitGuardCoverage $phpUnitGuardCoverage
*
* @return PhpUnitGuardCoverage
*/
public function configure(IOInterface $input, PhpUnitGuardCoverage $phpUnitGuardCoverage)
{
if (true === $phpUnitGuardCoverage->isUndefined()) {
$guardCoverageAnswer = $input->ask(HookQuestions::PHPUNIT_GUARD_COVERAGE, HookQuestions::DEFAULT_TOOL_ANSWER);
$phpUnitGuardCoverage = $phpUnitGuardCoverage->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($guardCoverageAnswer)));
if (true === $phpUnitGuardCoverage->isEnabled()) {
$defaultMessage = $input->ask(HookQuestions::PHPUNIT_GUARD_COVERAGE_MESSAGE, HookQuestions::PHPUNIT_GUARD_COVERAGE_MESSAGE_DEFAULT);
/** @var PhpUnitGuardCoverage $phpUnitGuardCoverage */
$phpUnitGuardCoverage = $phpUnitGuardCoverage->setWarningMessage(new Message($defaultMessage));
$this->coverageGitIgnoreConfigurator->configure();
}
}
return $phpUnitGuardCoverage;
}
示例8: processParams
protected function processParams($params, $actualParams)
{
if (!$this->io->isInteractive()) {
return $actualParams;
}
$this->io->write('<comment>Some parameters are missing. Please provide them.</comment>');
foreach ($params as $key => $value) {
$result = $this->io->ask(sprintf("<question>%s</question> (<comment>%s</comment>): ", $this->messages[$key], $value));
if (!empty($result)) {
$actualParams[$key] = $result;
}
}
return $actualParams;
}
示例9: configure
/**
* @param IOInterface $io
* @param PhpCsFixer $phpCsFixer
*
* @return PhpCsFixer
*/
public static function configure(IOInterface $io, PhpCsFixer $phpCsFixer)
{
if (true === $phpCsFixer->isUndefined()) {
$answer = $io->ask(HookQuestions::PHPCSFIXER_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
$phpCsFixer = $phpCsFixer->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
if (true === $phpCsFixer->isEnabled()) {
$psr0Answer = $io->ask(HookQuestions::PHPCSFIXER_PSR0_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER);
$psr1Answer = $io->ask(HookQuestions::PHPCSFIXER_PSR1_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER);
$psr2Answer = $io->ask(HookQuestions::PHPCSFIXER_PSR2_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER);
$symfonyAnswer = $io->ask(HookQuestions::PHPCSFIXER_SYMFONY_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER);
$phpCsFixer = $phpCsFixer->addLevels(new PhpCsFixerLevels(new Level(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($psr0Answer)), new Level(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($psr1Answer)), new Level(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($psr2Answer)), new Level(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($symfonyAnswer))));
}
}
return $phpCsFixer;
}
示例10: ask
public function ask($question, array $options)
{
$output = [];
$output[] = sprintf('<question>%s</question>', $question);
foreach ($options as $selection => $title) {
$output[] = sprintf('[<comment>%s</comment>] %s', $selection, $title);
}
while (1) {
$answer = $this->io->ask(implode(PHP_EOL, $output) . PHP_EOL);
if (!array_key_exists($answer, $options)) {
$this->io->write('<error>Invalid option selected.</error>');
} else {
return $answer;
}
}
}
示例11: start
public static function start(Configuration $configuration, IOInterface $io)
{
$params = array();
$params['database-model'] = $io->ask("> Database model? (MYSQLI) ", "MYSQLI");
$params['database-host'] = $io->ask("> Database host? (localhost) ", "localhost");
$params['database-port'] = $io->askAndValidate("> Database port? (3306) ", function ($value) {
return is_int($value);
}, 3, 3306);
$params['database-name'] = $io->ask("> Database name? (comodojo) ", "comodojo");
$params['database-user'] = $io->ask("> Database user? (comodojo) ", "comodojo");
$params['database-password'] = $io->askAndHideAnswer("> Database password? ");
$params['database-prefix'] = $io->ask("> Common prefix for database tables? (cmdj_) ", "cmdj_");
foreach ($params as $param => $value) {
$configuration->set($param, $value);
}
}
示例12: genSecretConfig
/**
* Generate database config. will store in: etc/secret.yml.
*
* @param IOInterface $io
*
* @return void
*/
protected static function genSecretConfig(IOInterface $io)
{
$etc = __DIR__ . '/../../../etc';
$secret = Yaml::parse(file_get_contents($etc . '/secret.dist.yml'));
$driver = 'mysql';
$host = $io->ask("Database host [localhost]: ", 'localhost');
$name = $io->ask("Database name [natika]: ", 'natika');
$user = $io->ask("Database user [root]: ", 'root');
$pass = $io->askAndHideAnswer("Database password: ");
$prefix = '';
$secret['database'] = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $pass, 'name' => $name, 'prefix' => $prefix);
file_put_contents($etc . '/secret.yml', Yaml::dump($secret, 4));
$io->write('');
$io->write('Database config setting complete.');
$io->write('');
}
示例13: treatParams
/**
* Treat params and display Q&A.
*
* @param array $expectedKeys
* @param boolean $isStarted
* @param string $prefix
*
* @since 0.0.3
*/
private function treatParams(array $expectedKeys, $isStarted = false, $prefix = '')
{
$params = [];
// Iterate on expected keys
foreach ($expectedKeys as $key => $message) {
if (is_array($message)) {
$params[$key] = $this->treatParams($message, $isStarted, $key);
} else {
// Display a first message before treating params
if (!$isStarted) {
$isStarted = true;
# Write
$this->io->write("\n<comment>Some parameters are missing. Please provide them.</comment>");
}
// Display prefix when its needed, treat special boolean case
$p = !empty($prefix) ? $prefix . ' ' : '';
$m = is_bool($message) && !$message ? '0' : $message;
# Read
$value = $this->io->ask(sprintf("<question>%s%s</question> (<comment>%s</comment>): ", $p, $key, $m), $message);
$value = is_bool($message) ? (bool) $value : (is_int($message) ? (int) $value : $value);
// Special case: 'debug'
if ('debug' === $key && $value) {
$params[$key] = $this->treatParams(['savequeries' => true, 'script_debug' => true, 'wp_debug_display' => true, 'wp_debug' => true], false, $key);
} else {
$params[$key] = $value;
}
}
}
return $params;
}
示例14: configure
/**
* @param IOInterface $io
* @param PhpUnit $phpUnit
*
* @return PhpUnit
*/
public static function configure(IOInterface $io, PhpUnit $phpUnit)
{
/** @var PhpUnit $phpUnit */
if (true === $phpUnit->isUndefined()) {
$answer = $io->ask(HookQuestions::PHPUNIT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
$phpUnit = $phpUnit->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
if (true === $phpUnit->isEnabled()) {
$randomAnswer = $io->ask(HookQuestions::PHPUNIT_RANDOM_MODE, HookQuestions::DEFAULT_TOOL_ANSWER);
$optionsAnswer = $io->ask(HookQuestions::PHPUNIT_OPTIONS, null);
$randomMode = new PhpUnitRandomMode(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($randomAnswer));
$options = new PhpUnitOptions($optionsAnswer);
$phpUnit = $phpUnit->setRandomModeAndOptions($randomMode, $options);
}
}
return $phpUnit;
}
示例15: configure
/**
* @param IOInterface $io
* @param PhpLint $phpLint
*
* @return PhpLint
*/
public static function configure(IOInterface $io, PhpLint $phpLint)
{
if (true === $phpLint->isUndefined()) {
$answer = $io->ask(HookQuestions::PHPLINT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
$phpLint = $phpLint->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
}
return $phpLint;
}