when we drop symfony 2.3 support, we should switch to the QuestionHelper (since 2.5) and drop this method as it adds no value
336702
public function askConfirmation($text, InputInterface $input = null)
    {
        if ($this->dialogHelper instanceof QuestionHelper) {
            if (!$input) {
                throw new \InvalidArgumentException('With symfony 3, the input stream may not be null');
            }
            return $this->dialogHelper->ask($input, $this, new ConfirmationQuestion($text));
        }

        if ($this->dialogHelper instanceof DialogHelper) {
            return $this->dialogHelper->askConfirmation($this, $text);
        }

        throw new \RuntimeException("Invalid dialogHelper");

    }
384227
protected function _droppedConstraintsStatement()
    {
        $columns = $this->_sql->getDroppedConstraints();
        if (empty($columns)) {
            return null;
        }

        return implode(', ', array_keys($columns));
    }
1066878
private function confirmRemoval(
        InputInterface $input,
        OutputInterface $output,
        $countryCode
    ) {
        /**
         * @var QuestionHelper $questionHelper
         */
        $questionHelper = $this->getHelper('question');
        $message = "<question>Country with code '$countryCode' will be dropped. Continue?</question>";

        return $questionHelper->ask(
            $input,
            $output,
            new ConfirmationQuestion($message, false)
        );
    }
615269
function CommandAsker(questions, options) {
    options = options || {};
    
    if (!_.isArray(questions)) {
        throw "there are no questions available :'(";
    }
    
    this.questions = questions;
    this.response = {};
    this.cli = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    this.askCallback = null;
    this.errorMsg = options.errorMsg || clc.xterm(160);
    this.currentQuestion = 0;
}
1168993
private function askAndValidate(InputInterface $input, OutputInterface $output, $questionText, $default, $validator)
    {
        $questionHelper = $this->getQuestionHelper();

        // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
        if ($questionHelper instanceof DialogHelper) {
            return $questionHelper->askAndValidate($output, $questionHelper->getQuestion($questionText, $default), $validator, false, $default);
        }

        $question = new Question($questionHelper->getQuestion($questionText, $default), $default);

        $question->setValidator($validator);

        return $questionHelper->ask($input, $output, $question);
    }
191139
public function getRequest()
    {
        if (null === $this->request) {
            @trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
            // throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
        }

        return $this->request;
    }
658235
public function negotiate()
    {
        // This is a workaround for PHP5.5, @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/143#issuecomment-108148498
        $catchedException = null;

        try {
            $this->lock->acquire();
            $this->executeMigrations();
        } catch (LockingException $exc) {
            $this->logger->emergency($exc->getMessage());

            $catchedException = $exc;
        } catch (TopologyViolationException $exc) {
            $this->logger->emergency('The version to migrate to is older than the current one.');

            $catchedException = $exc;
        } catch (MigrationException $exc) {
            $this->logger->emergency('Migration of version ' . $exc->getCode() . ' failed.', array($exc->getMessage()));

            $catchedException = $exc;
        }

        $this->lock->release();

        if (!is_null($catchedException)) {
            throw $catchedException;
        }
    }
956332
public function after_execute_question() {
        global $DB;

        // For random questions, questiontext should only ever be '0' or '1'.
        // In the past there were sometimes junk values like ''. If there
        // were any in the restore, fix them up.
        //
        // Note, we cannot just do this in one DB query, because MySQL is useless.
        // The expected case is that the SELECT returns 0 rows, so loading all the
        // ids should not be a problem.
        $problemquestions = $DB->get_records_sql_menu("
                SELECT q.id, 1
                  FROM {question} q
                  JOIN {backup_ids_temp} bi ON q.id = bi.newitemid
                 WHERE q.qtype = 'random'
                   AND " . $DB->sql_compare_text('q.questiontext') . " = ?
                   AND bi.backupid = ?
                   AND bi.itemname = 'question_created'
                ", array('', $this->get_restoreid()));

        if (!$problemquestions) {
            return; // Nothing to do.
        }

        list($idtest, $params) = $DB->get_in_or_equal(array_keys($problemquestions));
        $DB->set_field_select('question', 'questiontext', '0', "id $idtest", $params);
    }
1034507
protected function doInteract()
    {
        /**
         * Ask for which bundle we need to create the layout
         */
        $bundleNamespace = $this->assistant->getOptionOrDefault('namespace', null);
        $this->bundle = $this->askForBundleName('article classes', $bundleNamespace);

        /*
         * Entity
         */
        $this->entity = $this->assistant->getOptionOrDefault('entity', null);

        if (is_null($this->entity)) {
            $this->assistant->writeLine(array(
                'You must specify a name for the collection of Article entities.',
                'This name will be prefixed before every new entity.',
                'For example entering <comment>News</comment> will result in:',
                '<comment>News</comment>OverviewPage, <comment>News</comment>Page and <comment>News</comment>Author',
            ));

            $generator = $this->getGenerator();
            $this->entity = $this->assistant->askAndValidate(
                'Article class name',
                function ($name) use ($generator) {
                    // Check reserved words
                    if ($generator->isReservedKeyword($name)) {
                        throw new \InvalidArgumentException(sprintf('"%s" is a reserved word', $name));
                    }
                    if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $name)) {
                        throw new \InvalidArgumentException(sprintf('Invalid entity name: %s', $name));
                    }

                    return $name;
                }
            );
        }

        /*
         * Ask if author will be used
         */
        $this->usesAuthor = $this->askForAuthor();

        /*
         * Ask if category will be used
         */
        $this->usesCategories = $this->askForCategories();

        /*
         * Ask if tag will be used
         */
        $this->usesTags = $this->askForTags();

        /**
         * Ask the parent pages
         */
        $bundleWithHomePageNamespace = $this->assistant->getOptionOrDefault('namespacehomepage', null);
        $this->bundleWithHomePage = $this->askForBundleName('', $bundleWithHomePageNamespace, 'In which bundle is the page that you will use as parent for the overview page ?', "%sThe bundle %s will be used for the parent of the overview page.\n");
        $parentPages = $this->getAvailablePages($this->bundleWithHomePage);
        $pagesSelect = array_map(function ($item) {
            return $item['name'];
        }, $parentPages);
        if (count($pagesSelect) > 0) {
            $this->assistant->writeLine('');
            $parentPageNames = $this->assistant->getOptionOrDefault('articleoverviewpageparent', null);
            if (null !== $parentPageNames) {
                $parentPageNames = explode(',', $parentPageNames);
                foreach ($parentPageNames as $parentPageName) {
                    $id = array_search($parentPageName, $pagesSelect);
                    if (false !== $id) {
                        $this->parentPages[] = $parentPages[$id]['path'];
                    }
                }
            }

            if (empty($this->parentPages)) {
                $parentPageIds = $this->assistant->askSelect('Which existing page(s) can have the new overview page as sub-page (multiple possible, separated by comma)', $pagesSelect, null, true);
                foreach ($parentPageIds as $id) {
                    $this->parentPages[] = $parentPages[$id]['path'];
                }
            }
        }

        /*
         * Ask the database table prefix
         */
        $this->prefix = $this->assistant->getOptionOrDefault('prefix', null);
        if (is_null($this->prefix)) {
            $this->prefix = $this->askForPrefix(null, $this->bundle->getNamespace());
        }

        /*
         * Ask for data fixtures
         */
        $this->dummydata = $this->askForDummydata();
    }
364033
private function getQuestion($question, $default = null, callable $validator = null, array $values = null)
    {
        $question = new Question(
            sprintf('<info>%s</info>%s: ', $question, $default ? sprintf(' [<comment>%s</comment>]', $default) : ''),
            $default
        );

        $question
            ->setValidator($validator)
            ->setAutocompleterValues($values);

        return $question;
    }
12708
def method_missing(name, *args, &block)
      helpers.key?(name) ? helpers.fetch(name).call : super
    end
337560
public function getExtendedType()
    {
        if (!method_exists($this, 'getExtendedTypes')) {
            throw new LogicException(sprintf('You need to implement the static getExtendedTypes() method when implementing the %s in %s.', FormTypeExtensionInterface::class, static::class));
        }

        @trigger_error(sprintf('The %s::getExtendedType() method is deprecated since Symfony 4.2 and will be removed in 5.0. Use getExtendedTypes() instead.', \get_class($this)), E_USER_DEPRECATED);

        foreach (static::getExtendedTypes() as $extendedType) {
            return $extendedType;
        }
    }
1259301
protected function getSimpleQuestion()
    {
        if (!$this->getHelperSet()->has('simple_question')) {
            $this->getHelperSet()->set(new SimpleQuestionHelper());
        }

        return $this->getHelperSet()->get('simple_question');
    }
1127647
def method_missing(method, *args, &blck)
      if docs.respond_to?(method.to_sym)
        Bunto.logger.warn "Deprecation:",
          "#{label}.#{method} should be changed to #{label}.docs.#{method}."
        Bunto.logger.warn "", "Called by #{caller.first}."
        docs.public_send(method.to_sym, *args, &blck)
      else
        super
      end
    end
727180
function askForField(done) {
    this.log(chalk.green(`\nGenerating field #${this.fields.length + 1}\n`));
    const skipServer = this.skipServer;
    const databaseType = this.databaseType;
    const fieldNamesUnderscored = this.fieldNamesUnderscored;
    const prompts = [
        {
            type: 'confirm',
            name: 'fieldAdd',
            message: 'Do you want to add a field to your current page?',
            default: true
        },
        {
            when: response => response.fieldAdd === true,
            type: 'input',
            name: 'fieldName',
            validate: (input) => {
                if (!(/^([a-zA-Z0-9_]*)$/.test(input))) {
                    return 'Your field name cannot contain special characters';
                } else if (input === '') {
                    return 'Your field name cannot be empty';
                } else if (input.charAt(0) === input.charAt(0).toUpperCase()) {
                    return 'Your field name cannot start with an upper case letter';
                } else if (input === 'id' || fieldNamesUnderscored.indexOf(_.snakeCase(input)) !== -1) {
                    return 'Your field name cannot use an already existing field name';
                } else if (!skipServer && jhiCore.isReservedFieldName(input)) {
                    return 'Your field name cannot contain a Java or Angular reserved keyword';
                }
                return true;
            },
            message: 'What is the name of your field?'
        },
        {
            when: response => response.fieldAdd === true,
            type: 'list',
            name: 'fieldType',
            message: 'What is the type of your field?',
            choices: [
                {
                    value: 'String',
                    name: 'String'
                },
                {
                    value: 'Integer',
                    name: 'Integer'
                },
                {
                    value: 'Long',
                    name: 'Long'
                },
                {
                    value: 'Float',
                    name: 'Float'
                },
                {
                    value: 'Double',
                    name: 'Double'
                },
                {
                    value: 'BigDecimal',
                    name: 'BigDecimal'
                },
                {
                    value: 'LocalDate',
                    name: 'LocalDate'
                },
                {
                    value: 'Instant',
                    name: 'Instant'
                },
                {
                    value: 'ZonedDateTime',
                    name: 'ZonedDateTime'
                },
                {
                    value: 'Boolean',
                    name: 'Boolean'
                },
                {
                    value: 'enum',
                    name: 'Enumeration (Java enum type)'
                }
            ],
            default: 0
        },
        {
            when: (response) => {
                if (response.fieldType === 'enum') {
                    response.fieldIsEnum = true;
                    return true;
                }
                response.fieldIsEnum = false;
                return false;
            },
            type: 'input',
            name: 'fieldType',
            validate: (input) => {
                if (input === '') {
                    return 'Your class name cannot be empty.';
                } else if (jhiCore.isReservedKeyword(input, 'JAVA')) {
                    return 'Your enum name cannot contain a Java reserved keyword';
                }
                if (this.enums.indexOf(input) !== -1) {
                    this.existingEnum = true;
                } else {
                    this.enums.push(input);
                }
                return true;
            },
            message: 'What is the class name of your enumeration?'
        },
        {
            when: response => response.fieldIsEnum,
            type: 'input',
            name: 'fieldValues',
            validate: (input) => {
                if (input === '' && this.existingEnum) {
                    this.existingEnum = false;
                    return true;
                }
                if (input === '') {
                    return 'You must specify values for your enumeration';
                }
                if (!/^[A-Za-z0-9_,\s]*$/.test(input)) {
                    return 'Enum values cannot contain special characters (allowed characters: A-Z, a-z, 0-9 and _)';
                }
                const enums = input.replace(/\s/g, '').split(',');
                if (_.uniq(enums).length !== enums.length) {
                    return `Enum values cannot contain duplicates (typed values: ${input})`;
                }
                for (let i = 0; i < enums.length; i++) {
                    if (/^[0-9].*/.test(enums[i])) {
                        return `Enum value "${enums[i]}" cannot start with a number`;
                    }
                    if (enums[i] === '') {
                        return 'Enum value cannot be empty (did you accidentally type "," twice in a row?)';
                    }
                }

                return true;
            },
            message: (answers) => {
                if (!this.existingEnum) {
                    return 'What are the values of your enumeration (separated by comma)?';
                }
                return 'What are the new values of your enumeration (separated by comma)?\nThe new values will replace the old ones.\nNothing will be done if there are no new values.';
            }
        },
        {
            when: response => response.fieldAdd === true && this.pageType !== 'table',
            type: 'confirm',
            name: 'fieldValidate',
            message: 'Do you want to add validation rules to your field?',
            default: false
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                (response.fieldType === 'String' ||
                    response.fieldTypeBlobContent === 'text'),
            type: 'checkbox',
            name: 'fieldValidateRules',
            message: 'Which validation rules do you want to add?',
            choices: [
                {
                    name: 'Required',
                    value: 'required'
                },
                {
                    name: 'Minimum length',
                    value: 'minlength'
                },
                {
                    name: 'Maximum length',
                    value: 'maxlength'
                },
                {
                    name: 'Regular expression pattern',
                    value: 'pattern'
                }
            ],
            default: 0
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                (response.fieldType === 'Integer' ||
                    response.fieldType === 'Long' ||
                    response.fieldType === 'Float' ||
                    response.fieldType === 'Double' ||
                    response.fieldType === 'BigDecimal'),
            type: 'checkbox',
            name: 'fieldValidateRules',
            message: 'Which validation rules do you want to add?',
            choices: [
                {
                    name: 'Required',
                    value: 'required'
                },
                {
                    name: 'Minimum',
                    value: 'min'
                },
                {
                    name: 'Maximum',
                    value: 'max'
                }
            ],
            default: 0
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldType === 'byte[]' &&
                response.fieldTypeBlobContent !== 'text',
            type: 'checkbox',
            name: 'fieldValidateRules',
            message: 'Which validation rules do you want to add?',
            choices: [
                {
                    name: 'Required',
                    value: 'required'
                },
                {
                    name: 'Minimum byte size',
                    value: 'minbytes'
                },
                {
                    name: 'Maximum byte size',
                    value: 'maxbytes'
                }
            ],
            default: 0
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                (response.fieldType === 'LocalDate' ||
                    response.fieldType === 'Instant' ||
                    response.fieldType === 'ZonedDateTime' ||
                    response.fieldType === 'UUID' ||
                    response.fieldType === 'Boolean' ||
                    response.fieldType === 'ByteBuffer' ||
                    response.fieldIsEnum === true),
            type: 'checkbox',
            name: 'fieldValidateRules',
            message: 'Which validation rules do you want to add?',
            choices: [
                {
                    name: 'Required',
                    value: 'required'
                }
            ],
            default: 0
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('minlength') !== -1,
            type: 'input',
            name: 'fieldValidateRulesMinlength',
            validate: input => (this.isNumber(input) ? true : 'Minimum length must be a positive number'),
            message: 'What is the minimum length of your field?',
            default: 0
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('maxlength') !== -1,
            type: 'input',
            name: 'fieldValidateRulesMaxlength',
            validate: input => (this.isNumber(input) ? true : 'Maximum length must be a positive number'),
            message: 'What is the maximum length of your field?',
            default: 20
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('min') !== -1 &&
                (response.fieldType === 'Integer' ||
                    response.fieldType === 'Long'),
            type: 'input',
            name: 'fieldValidateRulesMin',
            message: 'What is the minimum of your field?',
            validate: input => (this.isSignedNumber(input) ? true : 'Minimum must be a number'),
            default: 0
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('max') !== -1 &&
                (response.fieldType === 'Integer' ||
                    response.fieldType === 'Long'),
            type: 'input',
            name: 'fieldValidateRulesMax',
            message: 'What is the maximum of your field?',
            validate: input => (this.isSignedNumber(input) ? true : 'Maximum must be a number'),
            default: 100
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('min') !== -1 &&
                (response.fieldType === 'Float' ||
                    response.fieldType === 'Double' ||
                    response.fieldType === 'BigDecimal'),
            type: 'input',
            name: 'fieldValidateRulesMin',
            message: 'What is the minimum of your field?',
            validate: input => (this.isSignedDecimalNumber(input, true) ? true : 'Minimum must be a decimal number'),
            default: 0
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('max') !== -1 &&
                (response.fieldType === 'Float' ||
                    response.fieldType === 'Double' ||
                    response.fieldType === 'BigDecimal'),
            type: 'input',
            name: 'fieldValidateRulesMax',
            message: 'What is the maximum of your field?',
            validate: input => (this.isSignedDecimalNumber(input, true) ? true : 'Maximum must be a decimal number'),
            default: 100
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('minbytes') !== -1 &&
                response.fieldType === 'byte[]' &&
                response.fieldTypeBlobContent !== 'text',
            type: 'input',
            name: 'fieldValidateRulesMinbytes',
            message: 'What is the minimum byte size of your field?',
            validate: input => (this.isNumber(input) ? true : 'Minimum byte size must be a positive number'),
            default: 0
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('maxbytes') !== -1 &&
                response.fieldType === 'byte[]' &&
                response.fieldTypeBlobContent !== 'text',
            type: 'input',
            name: 'fieldValidateRulesMaxbytes',
            message: 'What is the maximum byte size of your field?',
            validate: input => (this.isNumber(input) ? true : 'Maximum byte size must be a positive number'),
            default: 5000000
        },
        {
            when: response => response.fieldAdd === true &&
                response.fieldValidate === true &&
                response.fieldValidateRules.indexOf('pattern') !== -1,
            type: 'input',
            name: 'fieldValidateRulesPattern',
            message: 'What is the regular expression pattern you want to apply on your field?',
            default: '^[a-zA-Z0-9]*$'
        }
    ];
    this.prompt(prompts).then((props) => {
        if (props.fieldAdd) {
            if (props.fieldIsEnum) {
                props.fieldType = _.upperFirst(props.fieldType);
            }

            const field = {
                fieldName: props.fieldName,
                fieldType: props.fieldType,
                fieldTypeBlobContent: props.fieldTypeBlobContent,
                fieldValues: props.fieldValues,
                fieldValidateRules: props.fieldValidateRules,
                fieldValidateRulesMinlength: props.fieldValidateRulesMinlength,
                fieldValidateRulesMaxlength: props.fieldValidateRulesMaxlength,
                fieldValidateRulesPattern: props.fieldValidateRulesPattern,
                fieldValidateRulesMin: props.fieldValidateRulesMin,
                fieldValidateRulesMax: props.fieldValidateRulesMax,
                fieldValidateRulesMinbytes: props.fieldValidateRulesMinbytes,
                fieldValidateRulesMaxbytes: props.fieldValidateRulesMaxbytes
            };

            fieldNamesUnderscored.push(_.snakeCase(props.fieldName));
            this.fields.push(field);
        }
        if (props.fieldAdd) {
            askForField.call(this, done);
        } else {
            done();
        }
    });
}
444181
public function end(): QueryBuilderInterface
    {
        if (null === $this->node = $this->node->getParent()) {
            throw new \Exception(sprintf('You cannot call %s on main node', __FUNCTION__));
        }

        return $this;
    }
1070035
public function oldDispatch()
    {
        // For each update type
        foreach (BasicBot::$update_types as $offset => $class) {
            // Check if the bot has an inherited method
            if (method_exists($this, 'process' . $class)) {
                // Wrap it in a closure to make it works with the 3.0 version
                $this->answerUpdate[$offset] = function ($bot, $entity) use ($class) {
                    $bot->{"process$class"}($entity);
                };
            }
        }
    }