Exemple #1
0
 /**
  * Creates a {@see Type} from a PHPDoc type.
  *
  * @return Type
  */
 public function getTypes(DocType $varType)
 {
     $types = array();
     $nullable = false;
     if (!$varType instanceof Compound) {
         if ($varType instanceof Null_) {
             $nullable = true;
         }
         $type = $this->createType((string) $varType, $nullable);
         if (null !== $type) {
             $types[] = $type;
         }
         return $types;
     }
     $varTypes = array();
     for ($typeIndex = 0; $varType->has($typeIndex); ++$typeIndex) {
         $varTypes[] = (string) $varType->get($typeIndex);
     }
     // If null is present, all types are nullable
     $nullKey = array_search(Type::BUILTIN_TYPE_NULL, $varTypes);
     $nullable = false !== $nullKey;
     // Remove the null type from the type if other types are defined
     if ($nullable && count($varTypes) > 1) {
         unset($varTypes[$nullKey]);
     }
     foreach ($varTypes as $varType) {
         $type = $this->createType($varType, $nullable);
         if (null !== $type) {
             $types[] = $type;
         }
     }
     return $types;
 }
 /**
  * {@inheritDoc}
  */
 public function canApplyToType(Type $type)
 {
     // @todo validate also key type!
     return $type instanceof Array_ && $this->getCheckersApplicableToType($type->getValueType());
 }
 /**
  * {@inheritDoc}
  */
 public function canApplyToType(Type $type)
 {
     return $type instanceof Object_ && $type->getFqsen();
 }