/**
* 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);
}