private function getFunctionType($type = null, bool $isNullable, bool $isVariadic) : Type
{
if ($isVariadic) {
return new ArrayType($this->getFunctionType($type, $isNullable, false), false);
}
if ($type === null) {
return new MixedType(true);
} elseif ($type === 'string') {
return new StringType($isNullable);
} elseif ($type === 'int') {
return new IntegerType($isNullable);
} elseif ($type === 'bool') {
return new BooleanType($isNullable);
} elseif ($type === 'float') {
return new FloatType($isNullable);
} elseif ($type === 'callable') {
return new CallableType($isNullable);
} elseif ($type === 'array') {
return new ArrayType(new MixedType(true), $isNullable);
} elseif ($type instanceof Name) {
$className = (string) $type;
if ($className === 'self') {
$className = $this->getClass();
}
return new ObjectType($className, $isNullable);
} elseif ($type === 'iterable') {
return new IterableIterableType(new MixedType(true), $isNullable);
} elseif ($type === 'void') {
return new VoidType();
} elseif ($type instanceof Node\NullableType) {
return $this->getFunctionType($type->type, true, $isVariadic);
}
return new MixedType($isNullable);
}