@since Method available since Release 1.2.0
string $coveredElement:
array
protected function resolveCoversToReflectionObjects($coveredElement) {
$codeToCoverList = array();
if (strpos($coveredElement, '::') !== FALSE) {
list($className, $methodName) = explode('::', $coveredElement);
if (isset($methodName[0]) && $methodName[0] == '<') {
$classes = array(
$className,
);
foreach ($classes as $className) {
if (!class_exists($className) && !interface_exists($className)) {
throw new PHP_CodeCoverage_Exception(sprintf('Trying to @cover not existing class or ' . 'interface "%s".', $className));
}
$class = new ReflectionClass($className);
$methods = $class
->getMethods();
$inverse = isset($methodName[1]) && $methodName[1] == '!';
if (strpos($methodName, 'protected')) {
$visibility = 'isProtected';
}
else {
if (strpos($methodName, 'private')) {
$visibility = 'isPrivate';
}
else {
if (strpos($methodName, 'public')) {
$visibility = 'isPublic';
}
}
}
foreach ($methods as $method) {
if ($inverse && !$method
->{$visibility}()) {
$codeToCoverList[] = $method;
}
else {
if (!$inverse && $method
->{$visibility}()) {
$codeToCoverList[] = $method;
}
}
}
}
}
else {
$classes = array(
$className,
);
foreach ($classes as $className) {
if ($className == '' && function_exists($methodName)) {
$codeToCoverList[] = new ReflectionFunction($methodName);
}
else {
if (!((class_exists($className) || interface_exists($className) || trait_exists($className)) && method_exists($className, $methodName))) {
throw new PHP_CodeCoverage_Exception(sprintf('Trying to @cover not existing method "%s::%s".', $className, $methodName));
}
$codeToCoverList[] = new ReflectionMethod($className, $methodName);
}
}
}
}
else {
$extended = FALSE;
if (strpos($coveredElement, '<extended>') !== FALSE) {
$coveredElement = str_replace('<extended>', '', $coveredElement);
$extended = TRUE;
}
$classes = array(
$coveredElement,
);
if ($extended) {
$classes = array_merge($classes, class_implements($coveredElement), class_parents($coveredElement));
}
foreach ($classes as $className) {
if (!class_exists($className) && !interface_exists($className) && !trait_exists($className)) {
throw new PHP_CodeCoverage_Exception(sprintf('Trying to @cover not existing class or ' . 'interface "%s".', $className));
}
$codeToCoverList[] = new ReflectionClass($className);
}
}
return $codeToCoverList;
}