BetterReflection\Reflection\ReflectionType::createFromType PHP Метод

createFromType() публичный статический Метод

public static createFromType ( phpDocumentor\Reflection\Type $type, boolean $allowsNull ) : ReflectionType
$type phpDocumentor\Reflection\Type
$allowsNull boolean
Результат ReflectionType
    public static function createFromType(Type $type, $allowsNull)
    {
        $reflectionType = new self();
        $reflectionType->type = $type;
        $reflectionType->allowsNull = (bool) $allowsNull;
        return $reflectionType;
    }

Usage Example

 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));
 }
All Usage Examples Of BetterReflection\Reflection\ReflectionType::createFromType