/** * @return Type */ public function type() { if ($this->getter) { $analyzer = new MethodAnalyzer($this->getter); return $analyzer->getReturnType($this->types); } else { if ($this->setter) { $analyzer = new MethodAnalyzer($this->setter); $types = array_values($analyzer->getTypes($this->types)); return $types[0]; } } return new UnknownType(); }
function testNullableTypes() { $method = new MethodAnalyzer(new \ReflectionMethod(MethodAnalyzerTest_Foo::$CLASS, 'third')); $this->assertEquals($method->getTypes(new TypeFactory()), array('one' => new NullableType(new UnknownType()), 'two' => new NullableType(new StringType()), 'three' => new NullableType(new ClassType('DateTime')))); }