createFromType() public static method

public static createFromType ( phpDocumentor\Reflection\Type $type, boolean $allowsNull ) : ReflectionType
$type phpDocumentor\Reflection\Type
$allowsNull boolean
return ReflectionType
 public function testImplicitCastToString()
 {
     $this->assertSame('int', (string) ReflectionType::createFromType(new Types\Integer(), false));
     $this->assertSame('string', (string) ReflectionType::createFromType(new Types\String_(), false));
     $this->assertSame('array', (string) ReflectionType::createFromType(new Types\Array_(), false));
     $this->assertSame('callable', (string) ReflectionType::createFromType(new Types\Callable_(), false));
     $this->assertSame('bool', (string) ReflectionType::createFromType(new Types\Boolean(), false));
     $this->assertSame('float', (string) ReflectionType::createFromType(new Types\Float_(), false));
     $this->assertSame('void', (string) ReflectionType::createFromType(new Types\Void_(), false));
     $this->assertSame('\\Foo\\Bar\\Baz', (string) ReflectionType::createFromType(new Types\Object_(new Fqsen('\\Foo\\Bar\\Baz')), false));
 }
 /**
  * Get the return type declaration (only for PHP 7+ code)
  *
  * @return ReflectionType|null
  */
 public function getReturnType()
 {
     $namespaceForType = $this instanceof ReflectionMethod ? $this->getDeclaringClass()->getNamespaceName() : $this->getNamespaceName();
     $typeHint = (new FindTypeFromAst())->__invoke($this->node->getReturnType(), $this->getLocatedSource(), $namespaceForType);
     if (null === $typeHint) {
         return null;
     }
     return ReflectionType::createFromType($typeHint, false);
 }
 /**
  * Get the ReflectionType instance representing the type declaration for
  * this parameter
  *
  * (note: this has nothing to do with DocBlocks).
  *
  * @return ReflectionType|null
  */
 public function getType()
 {
     if (null === $this->getTypeHint()) {
         return null;
     }
     return ReflectionType::createFromType($this->getTypeHint(), $this->allowsNull());
 }