@@ -93,8 +93,9 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
9393 self ::$ ignoredLines [$ filename ] = array ();
9494 $ ignore = FALSE ;
9595 $ stop = FALSE ;
96+ $ lines = file ($ filename );
9697
97- foreach (file ( $ filename ) as $ index => $ line ) {
98+ foreach ($ lines as $ index => $ line ) {
9899 if (!trim ($ line )) {
99100 self ::$ ignoredLines [$ filename ][$ index +1 ] = TRUE ;
100101 }
@@ -111,6 +112,23 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
111112
112113 foreach ($ tokens as $ token ) {
113114 switch (get_class ($ token )) {
115+ case 'PHP_Token_DOC_COMMENT ' : {
116+ $ count = substr_count ($ token , "\n" );
117+ $ line = $ token ->getLine ();
118+
119+ for ($ i = $ line ; $ i < $ line + $ count ; $ i ++) {
120+ self ::$ ignoredLines [$ filename ][$ i ] = TRUE ;
121+ }
122+
123+ // Workaround for the fact the DOC_COMMENT token does
124+ // not include the final \n character in its text.
125+ if (trim ($ lines [$ i -1 ]) == '*/ ' ) {
126+ self ::$ ignoredLines [$ filename ][$ i ] = TRUE ;
127+ }
128+ }
129+ break ;
130+
131+ case 'PHP_Token_INTERFACE ' :
114132 case 'PHP_Token_TRAIT ' :
115133 case 'PHP_Token_CLASS ' :
116134 case 'PHP_Token_FUNCTION ' : {
@@ -124,8 +142,9 @@ public static function getLinesToBeIgnored($filename, $cacheTokens = TRUE)
124142 }
125143 }
126144
127- else if (($ token instanceof PHP_Token_TRAIT ||
128- $ token instanceof PHP_Token_CLASS)) {
145+ else if ($ token instanceof PHP_Token_INTERFACE ||
146+ $ token instanceof PHP_Token_TRAIT ||
147+ $ token instanceof PHP_Token_CLASS) {
129148 if (empty ($ classes [$ token ->getName ()]['methods ' ])) {
130149 for ($ i = $ token ->getLine ();
131150 $ i <= $ token ->getEndLine ();
0 commit comments