Exemplo n.º 1
0
 /**
  * Get the type string for the given parameter name.
  *
  * @param $name
  *
  * @return \Box\TestScribe\PHPDoc\PHPDocType
  */
 public function getParamTypeString($name)
 {
     // @TODO (ryang 5/31/14) : handle parameters with multiple types and array type.
     $argumentService = new MethodArgumentService();
     // @TODO (ryang 12/5/14) : optimization: scan all parameters in one pass.
     // Check if the parameter is a class and has type information using type hinting
     $paramClassName = $argumentService->getFullyQualifiedClassNameIfAvailable($this->reflectionMethod, $name);
     if ($paramClassName) {
         $type = PHPDoc\PHPDocType::lookup($paramClassName);
     } else {
         // Fall back to PHPDoc
         $type = $this->getParamInfo($name);
     }
     return $type;
 }
Exemplo n.º 2
0
 /**
  * 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];
 }