@@ -674,7 +674,7 @@ protected function getLinesToBeCovered($className, $methodName)
674674 }
675675
676676 $ classShortcut = preg_match_all (
677- '(@coversDefaultClass\s+(?P<coveredClass>.*? )\s*$)m ' ,
677+ '(@coversDefaultClass\s+(?P<coveredClass>[^\s]++ )\s*$)m ' ,
678678 $ class ->getDocComment (),
679679 $ matches
680680 );
@@ -693,7 +693,7 @@ protected function getLinesToBeCovered($className, $methodName)
693693 }
694694
695695 $ match = preg_match_all (
696- '(@covers\s+(?P<coveredElement>.*?)\s*(\(\s*\))?\s *$)m ' ,
696+ '(@covers\s+(?P<coveredElement>[^\s()]++)[\s()] *$)m ' ,
697697 $ docComment ,
698698 $ matches
699699 );
@@ -895,25 +895,9 @@ protected function getLinesToBeIgnored($filename)
895895 switch (get_class ($ token )) {
896896 case 'PHP_Token_COMMENT ' :
897897 case 'PHP_Token_DOC_COMMENT ' : {
898- $ count = substr_count ($ token , "\n" );
899- $ line = $ token ->getLine ();
900-
901- for ($ i = $ line ; $ i < $ line + $ count ; $ i ++) {
902- $ this ->ignoredLines [$ filename ][] = $ i ;
903- }
904-
905- if ($ token instanceof PHP_Token_DOC_COMMENT) {
906- // Workaround for the fact the DOC_COMMENT token
907- // does not include the final \n character in its
908- // text.
909- if (substr (trim ($ lines [$ i -1 ]), -2 ) == '*/ ' ) {
910- $ this ->ignoredLines [$ filename ][] = $ i ;
911- }
912-
913- break ;
914- }
915898
916899 $ _token = trim ($ token );
900+ $ _line = trim ($ lines [$ token ->getLine () - 1 ]);
917901
918902 if ($ _token == '// @codeCoverageIgnore ' ||
919903 $ _token == '//@codeCoverageIgnore ' ) {
@@ -930,6 +914,26 @@ protected function getLinesToBeIgnored($filename)
930914 $ _token == '//@codeCoverageIgnoreEnd ' ) {
931915 $ stop = TRUE ;
932916 }
917+
918+ // be sure the comment doesn't have some token BEFORE it on the same line...
919+ // it would not be safe to ignore the whole line in those cases.
920+ if (0 === strpos ($ _token , $ _line )) {
921+ $ count = substr_count ($ token , "\n" );
922+ $ line = $ token ->getLine ();
923+
924+ for ($ i = $ line ; $ i < $ line + $ count ; $ i ++) {
925+ $ this ->ignoredLines [$ filename ][] = $ i ;
926+ }
927+
928+ if ($ token instanceof PHP_Token_DOC_COMMENT) {
929+ // Workaround for the fact the DOC_COMMENT token
930+ // does not include the final \n character in its
931+ // text.
932+ if (substr (trim ($ lines [$ i -1 ]), -2 ) == '*/ ' ) {
933+ $ this ->ignoredLines [$ filename ][] = $ i ;
934+ }
935+ }
936+ }
933937 }
934938 break ;
935939
0 commit comments