diff --git a/src/Barryvdh/Reflection/DocBlock/Type/Collection.php b/src/Barryvdh/Reflection/DocBlock/Type/Collection.php index cf8c9f3..dca3c83 100644 --- a/src/Barryvdh/Reflection/DocBlock/Type/Collection.php +++ b/src/Barryvdh/Reflection/DocBlock/Type/Collection.php @@ -151,6 +151,10 @@ class Collection extends \ArrayObject return ''; } + if($this->shouldBeAbsolute($type)){ + return self::OPERATOR_NAMESPACE . $type; + } + if ($this->isTypeAnArray($type)) { return $this->expand(substr($type, 0, -2)) . self::OPERATOR_ARRAY; } @@ -218,4 +222,16 @@ class Collection extends \ArrayObject return ($type[0] !== self::OPERATOR_NAMESPACE) || $this->isTypeAKeyword($type); } + + /** + * Detects if the type should actually be absolute, by checking if it exists. + * + * @param string $type A relative or absolute type as defined in the + * phpDocumentor documentation. + * + * @return bool + */ + protected function shouldBeAbsolute($type){ + return class_exists($type); + } }