Exemple #1
0
 /**
  * @param string $docString PHPDocString for a parameter or the return value
  * @param string $subject description of what the type is for
  *
  * @return \Box\TestScribe\PHPDoc\PHPDocType
  */
 private function parsePHPDocString($docString, $subject)
 {
     try {
         $typeInfo = PHPDoc\PHPDocType::lookup($docString);
     } catch (PHPDocTypeException $e) {
         $detailedExceptionMsg = $e->getMessage();
         $invalidTypeWarningMsg = "Failed to parse PHPDoc type string ( {$docString} ) for the {$subject}.\n" . "Detailed exception message ( {$detailedExceptionMsg} )\n" . "Assume mixed type.";
         App::writeln($invalidTypeWarningMsg);
         $typeInfo = new PHPDocMixedType();
     }
     return $typeInfo;
 }
 /**
  * Prompt users to select a type from a list of types.
  *
  * @param PHPDocType $type
  *
  * @return PHPDocType
  */
 public function getSingleTypeFromComposite($type)
 {
     $types = $type->getTypes();
     $count = count($types);
     $message = sprintf('Found multiple types ( %s ). Please enter the type desired: ', $type);
     App::writeln($message);
     for ($i = 0; $i < $count; $i++) {
         $message = sprintf("%d %s", $i, $types[$i]->getRepresentation());
         App::writeln($message);
     }
     $message = sprintf("Enter number 0 - %s representing type intended.", $count - 1);
     App::writeln($message);
     $userInputObj = new UserInput();
     $input = $userInputObj->getInteger();
     return $types[$input];
 }