@@ -114,25 +114,9 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
114114 switch (get_class ($ token )) {
115115 case 'PHP_Token_COMMENT ' :
116116 case 'PHP_Token_DOC_COMMENT ' : {
117- $ count = substr_count ($ token , "\n" );
118- $ line = $ token ->getLine ();
119-
120- for ($ i = $ line ; $ i < $ line + $ count ; $ i ++) {
121- self ::$ ignoredLines [$ filename ][$ i ] = TRUE ;
122- }
123-
124- if ($ token instanceof PHP_Token_DOC_COMMENT) {
125- // Workaround for the fact the DOC_COMMENT token
126- // does not include the final \n character in its
127- // text.
128- if (substr (trim ($ lines [$ i -1 ]), -2 ) == '*/ ' ) {
129- self ::$ ignoredLines [$ filename ][$ i ] = TRUE ;
130- }
131-
132- break ;
133- }
134117
135118 $ _token = trim ($ token );
119+ $ _line = trim ($ lines [$ token ->getLine () - 1 ]);
136120
137121 if ($ _token == '// @codeCoverageIgnore ' ||
138122 $ _token == '//@codeCoverageIgnore ' ) {
@@ -149,6 +133,26 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
149133 $ _token == '//@codeCoverageIgnoreEnd ' ) {
150134 $ stop = TRUE ;
151135 }
136+
137+ // be sure the comment doesn't have some token BEFORE it on the same line...
138+ // it would not be safe to ignore the whole line in those cases.
139+ if (0 === strpos ($ _token , $ _line )) {
140+ $ count = substr_count ($ token , "\n" );
141+ $ line = $ token ->getLine ();
142+
143+ for ($ i = $ line ; $ i < $ line + $ count ; $ i ++) {
144+ self ::$ ignoredLines [$ filename ][$ i ] = TRUE ;
145+ }
146+
147+ if ($ token instanceof PHP_Token_DOC_COMMENT) {
148+ // Workaround for the fact the DOC_COMMENT token
149+ // does not include the final \n character in its
150+ // text.
151+ if (substr (trim ($ lines [$ i -1 ]), -2 ) == '*/ ' ) {
152+ self ::$ ignoredLines [$ filename ][$ i ] = TRUE ;
153+ }
154+ }
155+ }
152156 }
153157 break ;
154158
0 commit comments