@@ -853,21 +853,27 @@ protected static function resolveCoversToReflectionObjects($coveredElement)
853853 $ classes = array ($ className );
854854
855855 foreach ($ classes as $ className ) {
856- if (!((class_exists ($ className ) ||
857- interface_exists ($ className )) &&
858- method_exists ($ className , $ methodName ))) {
859- throw new RuntimeException (
860- sprintf (
861- 'Trying to @cover not existing method "%s::%s". ' ,
862- $ className ,
863- $ methodName
864- )
856+ if ($ className == '' && function_exists ($ methodName )) {
857+ $ codeToCoverList [] = new ReflectionFunction (
858+ $ methodName
865859 );
866- }
860+ } else {
861+ if (!((class_exists ($ className ) ||
862+ interface_exists ($ className )) &&
863+ method_exists ($ className , $ methodName ))) {
864+ throw new RuntimeException (
865+ sprintf (
866+ 'Trying to @cover not existing method "%s::%s". ' ,
867+ $ className ,
868+ $ methodName
869+ )
870+ );
871+ }
867872
868- $ codeToCoverList [] = new ReflectionMethod (
869- $ className , $ methodName
870- );
873+ $ codeToCoverList [] = new ReflectionMethod (
874+ $ className , $ methodName
875+ );
876+ }
871877 }
872878 }
873879 } else {
@@ -892,12 +898,7 @@ class_parents($coveredElement)
892898 }
893899
894900 foreach ($ classes as $ className ) {
895- if (function_exists ($ className )) {
896- $ codeToCoverList [] = new ReflectionFunction ($ className );
897- continue ;
898- }
899-
900- else if (!class_exists ($ className ) &&
901+ if (!class_exists ($ className ) &&
901902 !interface_exists ($ className )) {
902903 throw new RuntimeException (
903904 sprintf (
0 commit comments