Example #1
0
 public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNested)
 {
     $prefix = Caster::PREFIX_VIRTUAL;
     $a += array($prefix . 'name' => method_exists('ReflectionType', 'getName') ? $c->getName() : $c->__toString(), $prefix . 'allowsNull' => $c->allowsNull(), $prefix . 'isBuiltin' => $c->isBuiltin());
     return $a;
 }
 public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNested)
 {
     $prefix = Caster::PREFIX_VIRTUAL;
     $a += array($prefix . 'type' => $c->__toString(), $prefix . 'allowsNull' => $c->allowsNull(), $prefix . 'isBuiltin' => $c->isBuiltin());
     return $a;
 }
 /**
  * Extracts data from the PHP 7 reflection type.
  *
  * @param \ReflectionType $reflectionType
  *
  * @return Type
  */
 private function extractFromReflectionType(\ReflectionType $reflectionType)
 {
     $phpTypeOrClass = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : $reflectionType->__toString();
     $nullable = $reflectionType->allowsNull();
     if (Type::BUILTIN_TYPE_ARRAY === $phpTypeOrClass) {
         $type = new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true);
     } elseif ('void' === $phpTypeOrClass) {
         $type = new Type(Type::BUILTIN_TYPE_NULL, $nullable);
     } elseif ($reflectionType->isBuiltin()) {
         $type = new Type($phpTypeOrClass, $nullable);
     } else {
         $type = new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $phpTypeOrClass);
     }
     return $type;
 }