File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change 4747 define ('T_NAMESPACE ' , 377 );
4848}
4949
50+ require_once 'PHP/Token/Stream.php ' ;
51+
5052/**
5153 * Utility methods.
5254 *
@@ -264,25 +266,32 @@ public static function getLinesToBeIgnored($filename)
264266 if (!isset (self ::$ ignoredLines [$ filename ])) {
265267 self ::$ ignoredLines [$ filename ] = array ();
266268
267- $ ignore = FALSE ;
268- $ lineNum = 1 ;
269+ $ ignore = FALSE ;
270+ $ stop = FALSE ;
271+ $ tokens = new PHP_Token_Stream ($ filename );
269272
270- foreach (file ($ filename ) as $ line ) {
271- $ trimmedLine = trim ($ line );
273+ foreach ($ tokens as $ token ) {
274+ switch (get_class ($ token )) {
275+ case 'PHP_Token_COMMENT ' : {
276+ if (trim ($ token ) == '// @codeCoverageIgnoreStart ' ) {
277+ $ ignore = TRUE ;
278+ }
272279
273- if ($ trimmedLine == '// @codeCoverageIgnoreStart ' ) {
274- $ ignore = TRUE ;
280+ else if (trim ($ token ) == '// @codeCoverageIgnoreEnd ' ) {
281+ $ stop = TRUE ;
282+ }
283+ }
284+ break ;
275285 }
276286
277287 if ($ ignore ) {
278- self ::$ ignoredLines [$ filename ][$ lineNum ] = TRUE ;
288+ self ::$ ignoredLines [$ filename ][$ token -> getLine () ] = TRUE ;
279289
280- if ($ trimmedLine == ' // @codeCoverageIgnoreEnd ' ) {
290+ if ($ stop ) {
281291 $ ignore = FALSE ;
292+ $ stop = FALSE ;
282293 }
283294 }
284-
285- $ lineNum ++;
286295 }
287296 }
288297
You can’t perform that action at this time.
0 commit comments