original_string: public function asQuestion()
      {
          $instance = $this->questionClassInstance()
              ->setMaxAttempts($this->maxAttempt);
  
          // Set question instance hidden if defined by the field.
          if ($this->hidden) {
              $instance->setHidden(true);
          }
  
          // Set validation callback if field is required.
          if ($this->isRequire()) {
              $this->setValidation(function ($answer) {
                  if ($answer == ''
                      && $this->dataType() !== 'boolean') {
                      throw new \Exception('Field is required.');
                  }
              });
          }
  
          // Set question instance validator callback.
          $instance->setValidator(function ($answer) {
  
              // Iterate over all field validation callbacks.
              foreach ($this->validation as $callback) {
                  if (!is_callable($callback)) {
                      continue;
                  }
  
                  $callback($answer);
              }
  
              return $answer;
          });
  
          // Set question normalizer based on the field normalizer. If a default
          // normalizer is being set from the question class then setting the
          // normalizer will trump it's execution, as only one normalizer can be
          // set per question instance.
          if (isset($this->normalizer)
              && is_callable($this->normalizer)) {
              $instance->setNormalizer($this->normalizer);
          }
  
          return $instance;
      }
code: public function asQuestion()
      {
          $instance = $this->questionClassInstance()
              ->setMaxAttempts($this->maxAttempt);
  
          // Set question instance hidden if defined by the field.
          if ($this->hidden) {
              $instance->setHidden(true);
          }
  
          // Set validation callback if field is required.
          if ($this->isRequire()) {
              $this->setValidation(function ($answer) {
                  if ($answer == ''
                      && $this->dataType() !== 'boolean') {
                      throw new \Exception('Field is required.');
                  }
              });
          }
  
          // Set question instance validator callback.
          $instance->setValidator(function ($answer) {
  
              // Iterate over all field validation callbacks.
              foreach ($this->validation as $callback) {
                  if (!is_callable($callback)) {
                      continue;
                  }
  
                  $callback($answer);
              }
  
              return $answer;
          });
  
          // Set question normalizer based on the field normalizer. If a default
          // normalizer is being set from the question class then setting the
          // normalizer will trump it's execution, as only one normalizer can be
          // set per question instance.
          if (isset($this->normalizer)
              && is_callable($this->normalizer)) {
              $instance->setNormalizer($this->normalizer);
          }
  
          return $instance;
      }
code_tokens: public function asQuestion ( ) { $ instance = $ this -> questionClassInstance ( ) -> setMaxAttempts ( $ this -> maxAttempt ) ; // Set question instance hidden if defined by the field. if ( $ this -> hidden ) { $ instance -> setHidden ( true ) ; } // Set validation callback if field is required. if ( $ this -> isRequire ( ) ) { $ this -> setValidation ( function ( $ answer ) { if ( $ answer == '' && $ this -> dataType ( ) !== 'boolean' ) { throw new \ Exception ( 'Field is required.' ) ; } } ) ; } // Set question instance validator callback. $ instance -> setValidator ( function ( $ answer ) { // Iterate over all field validation callbacks. foreach ( $ this -> validation as $ callback ) { if ( ! is_callable ( $ callback ) ) { continue ; } $ callback ( $ answer ) ; } return $ answer ; } ) ; // Set question normalizer based on the field normalizer. If a default // normalizer is being set from the question class then setting the // normalizer will trump it's execution, as only one normalizer can be // set per question instance. if ( isset ( $ this -> normalizer ) && is_callable ( $ this -> normalizer ) ) { $ instance -> setNormalizer ( $ this -> normalizer ) ; } return $ instance ; }
docstring: Field as question instance.
  
  @return \Symfony\Component\Console\Question\Question
docstring_tokens: Field as question instance .