Skip to content

Commit bae8be0

Browse files
committed
Test for false relative paths
Closure -> \Closure etc
1 parent 3a5d30e commit bae8be0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Barryvdh/Reflection/DocBlock/Type/Collection.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ protected function expand($type)
151151
return '';
152152
}
153153

154+
if($this->shouldBeAbsolute($type)){
155+
return self::OPERATOR_NAMESPACE . $type;
156+
}
157+
154158
if ($this->isTypeAnArray($type)) {
155159
return $this->expand(substr($type, 0, -2)) . self::OPERATOR_ARRAY;
156160
}
@@ -218,4 +222,16 @@ protected function isRelativeType($type)
218222
return ($type[0] !== self::OPERATOR_NAMESPACE)
219223
|| $this->isTypeAKeyword($type);
220224
}
225+
226+
/**
227+
* Detects if the type should actually be absolute, by checking if it exists.
228+
*
229+
* @param string $type A relative or absolute type as defined in the
230+
* phpDocumentor documentation.
231+
*
232+
* @return bool
233+
*/
234+
protected function shouldBeAbsolute($type){
235+
return class_exists($type);
236+
}
221237
}

0 commit comments

Comments
 (0)