From bae8be0dcd090bab099b2f355350aa713246a109 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sat, 8 Jun 2013 22:53:54 +0200 Subject: [PATCH] Test for false relative paths Closure -> \Closure etc --- .../Reflection/DocBlock/Type/Collection.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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); + } }