Test for false relative paths

Closure -> \Closure etc
This commit is contained in:
Barry vd. Heuvel
2013-06-08 22:53:54 +02:00
parent 3a5d30e027
commit bae8be0dcd
@@ -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);
}
}