public function interact(QuestionsSet $questions)
 {
     $questions->communicate('sf_bundle_name', Question::ask('Bundle name', function (array $configuration) {
         $bundleName = strtr($configuration['namespace'], ['\\Bundle\\' => '', '\\' => '']);
         $bundleName .= substr($bundleName, -6) === 'Bundle' ? '' : 'Bundle';
         return $bundleName;
     }, function ($bundle) {
         if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $bundle)) {
             throw new \InvalidArgumentException(sprintf('The bundle name %s contains invalid characters.', $bundle));
         }
         if (!preg_match('/Bundle$/', $bundle)) {
             throw new \InvalidArgumentException('The bundle name must end with Bundle.');
         }
         return $bundle;
     }));
     $questions->communicate('sf_extension_name', Question::ask('Bundle Extension name', function (array $configuration) {
         return substr($configuration['sf_bundle_name'], 0, -6);
     })->markOptional());
     $questions->communicate('sf_extension_alias', Question::ask('Bundle Extension alias', function (array $configuration) {
         return StringUtil::underscore(substr($configuration['sf_bundle_name'], 0, -6));
     })->markOptional());
     $questions->communicate('sf_bundle_config_format', Question::choice('Configuration format', ['yml', 'xml'], 1));
     // XXX Add confirm for: routing (format), Configuration class, service file location (allow null)
     // type of the bundle (http-kernel of framework), full structure (form, controller)
     // separate generator
 }
 public function interact(QuestionsSet $questions)
 {
     if ('MPL-2.0' === $questions->communicate('license', Question::choice('License', self::getLicenses(), 'MIT')->setHelp('Labeled with "+" means higher inclusive'))) {
         $questions->communicate('license_secondary_incompatibility', Question::confirm('Incompatible With Secondary Licenses?', false));
     } else {
         $questions->set('license_secondary_incompatibility', false);
     }
 }
 public function interact(QuestionsSet $questions)
 {
     $format = $questions->communicate('doc_format', Question::choice('Documentation format', ['rst', 'markdown', 'none']));
     if ('rst' === $format) {
         $questions->communicate('rst_short_name', Question::ask('Short product name', function (array $config) {
             return StringUtil::shortProductName($config['name']);
         }));
     }
 }
 public function interact(QuestionsSet $questions)
 {
     $questions->communicate('composer_type', Question::ask('Composer package type', 'library'));
     if ('stable' !== $questions->communicate('composer_minimum_stability', Question::choice('Minimum stability', ['dev', 'alpha', 'beta', 'RC', 'stable'], 'stable')->markOptional())) {
         $questions->communicate('composer_prefer_stable', Question::confirm('Prefer stable?', true)->markOptional());
     } else {
         $questions->set('composer_prefer_stable', false);
     }
 }
 public function run(ResolvedProfile $profile, array $generators, QuestionsSet $answers)
 {
     $this->reportHeader($profile);
     $i = 1;
     $total = count($generators);
     $configuration = $answers->getFinalizedValues($profile->configurators);
     $startTime = microtime(true);
     $this->style->text(['', '<fg=green>Start dancing, this may take a while...</>', sprintf('Total of tasks: %d', $total), '']);
     foreach ($generators as $generator) {
         $this->runGenerator($generator, $configuration, $i, $total);
         ++$i;
     }
     if ($this->style->isVerbose()) {
         $this->style->text(['', sprintf('// Total time: %s, Memory: %4.2fMB', self::secondsToTimeString(microtime(true) - $startTime), memory_get_peak_usage(true) / 1048576)]);
     }
     $this->style->success('Done!');
 }
 public function interact(QuestionsSet $questions)
 {
     $questions->communicate('enable_phpunit', Question::confirm('Enable PHPUnit?', true));
     if ($questions->communicate('enable_phpspec', Question::confirm('Enable PHPSpec?', false))) {
         $questions->communicate('phpspec_suite_name', Question::confirm('PHPSpec suite-name', function (array $values) {
             return isset($values['name']) ? StringUtil::shortProductName($values['name']) : null;
         }));
     } else {
         $questions->set('phpspec_shortname', null);
     }
     if ($questions->communicate('enable_behat', Question::confirm('Enable Behat?', false))) {
         $questions->communicate('behat_suite_name', Question::ask('Behat suite-name', function (array $values) {
             return isset($values['name']) ? StringUtil::shortProductName($values['name']) : null;
         }));
     } else {
         $questions->set('behat_shortname', null);
     }
     $questions->communicate('enable_mink', Question::confirm('Enable Mink?', false));
 }
 public function interact(QuestionsSet $questions)
 {
     $questions->communicate('name', Question::ask('Name'));
     $questions->communicate('package_name', Question::ask('Package name (<vendor>/<name>)', function (array $config) {
         if ('' !== (string) $config['name'] && preg_match('/^(?P<vendor>[a-z0-9_.-]+)\\s+(?P<name>[a-z0-9_.-]+)$/i', $config['name'], $regs)) {
             return strtolower(StringUtil::humanize($regs[1]) . '/' . StringUtil::humanize($regs[2]));
         }
     }, function ($name) {
         if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}', $name)) {
             throw new \InvalidArgumentException('The package name ' . $name . ' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+');
         }
         return $name;
     }));
     $questions->communicate('namespace', Question::ask('PHP Namespace', null, function ($namespace) {
         $namespace = trim(str_replace('/', '\\', $namespace), '\\');
         if (!preg_match('/^(?:[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*\\\\?)+$/', $namespace)) {
             throw new \InvalidArgumentException('The namespace contains invalid characters.');
         }
         // validate reserved keywords
         $reserved = self::getReservedWords();
         foreach (explode('\\', $namespace) as $word) {
             if (in_array(strtolower($word), $reserved, true)) {
                 throw new \InvalidArgumentException(sprintf('The namespace cannot contain PHP reserved words ("%s").', $word));
             }
         }
         return $namespace;
     }));
     $questions->communicate('author_name', Question::ask('Author name', function () {
         return $this->git->getGitConfig('user.name', 'global');
     }));
     $questions->communicate('author_email', Question::ask('Author e-mail', function () {
         return $this->git->getGitConfig('user.email', 'global');
     }));
     $questions->communicate('php_min', Question::ask('Php-min', substr(PHP_VERSION, 0, 3)));
     $questions->communicate('src_dir', Question::ask('PHP source directory', 'src', function ($value) {
         return trim($value, '/');
     })->markOptional('.'));
 }
 public function interact(QuestionsSet $questions)
 {
     $questions->communicate('profiles', Question::multiChoice('Profiles to enable (dumps all questions for ease of use)', array_keys($this->config->getProfiles())));
 }
 public function interact(QuestionsSet $questions)
 {
     $questions->communicate('php_cs_preset', Question::choice('PHP-CS Preset', ['none', 'psr1', 'psr2', 'symfony', 'laravel', 'recommended'], 'symfony'));
     $questions->communicate('php_cs_enabled_fixers', Question::ask('PHP-CS Fixers', 'none', function ($value) {
         if ('none' === $value) {
             return $value;
         }
         $fixers = $this->splitValues($value);
         $fixers = array_unique($fixers);
         foreach ($fixers as $fixer) {
             $fixer = trim($fixer);
             if (!in_array($fixer, Fixers::$valid, true)) {
                 throw new \InvalidArgumentException(sprintf('Fixer "%s" is not supported.', $fixer));
             }
             if (isset(Fixers::$conflicts[$fixer]) && ($conflicts = array_intersect((array) Fixers::$conflicts[$fixer], $fixers))) {
                 throw new \InvalidArgumentException(sprintf('Fixer "%s" conflicts with fixers "%s".', $fixer, implode('", "', $conflicts)));
             }
             // XXX Need to validate 'here' if the enabled fixers conflict with the preset.
         }
         return $value;
     })->markOptional('none'));
     $questions->communicate('php_cs_disabled_fixers', Question::ask('PHP-CS Disabled fixers', 'none', function ($value) {
         if ('none' === $value) {
             return $value;
         }
         $fixers = $this->splitValues($value);
         $fixers = array_unique($fixers);
         foreach ($fixers as $fixer) {
             $fixer = trim($fixer);
             if (!in_array($fixer, Fixers::$valid, true)) {
                 throw new \InvalidArgumentException(sprintf('Fixer "%s" is not supported.', $fixer));
             }
         }
         return $value;
     })->markOptional('none'));
     $questions->communicate('php_cs_linting', Question::confirm('Enable PHP-CS linting?', false));
     if ($questions->communicate('styleci_enabled', Question::confirm('Enable StyleCI (local configuration)?', true))) {
         $questions->set('php_cs_version_1_bc', false);
         $questions->communicate('php_cs_styleci_bridge', Question::confirm('Enable StyleCI bridge', true));
     } else {
         $questions->set('php_cs_styleci_bridge', false);
         $questions->communicate('php_cs_version_1_bc', Question::confirm('Enable PHP-CS v1 compatibility?', true));
     }
     // Finder questions.
     $questions->communicate('php_cs_finder_path', Question::ask('PHP-CS Finder {path}', 'src', false)->markOptional());
     $questions->communicate('php_cs_finder_not_path', Question::ask('PHP-CS Finder {not path}', '!*', false)->markOptional('!*'));
     $questions->communicate('php_cs_finder_exclude', Question::ask('PHP-CS Finder {exclude dirs}', '!*', false)->markOptional('!*'));
     $questions->communicate('php_cs_finder_name', Question::ask('PHP-CS Finder {name}', '*', false)->markOptional('*'));
     $questions->communicate('php_cs_finder_not_name', Question::ask('PHP-CS Finder {not name}', '!*', false)->markOptional('!*'));
     $questions->communicate('php_cs_finder_contains', Question::ask('PHP-CS Finder {contains}', '*', false)->markOptional('*'));
     $questions->communicate('php_cs_finder_not_contains', Question::ask('PHP-CS Finder {not contains}', '!*', false)->markOptional('!*'));
     $questions->communicate('php_cs_finder_depth', Question::ask('PHP-CS Finder {depth}', '*', false)->markOptional('*'));
 }
 private function storeCache(ResolvedProfile $profile, QuestionsSet $questionsSet)
 {
     file_put_contents($this->config->get('current_dir') . '/' . self::CACHE_FILENAME, json_encode(['profile' => $profile->name, 'defaults' => $questionsSet->getAnswers(), 'skip_option' => $this->runner->skipOptional()], JSON_PRETTY_PRINT));
 }