File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -699,14 +699,15 @@ public static function stripComments($source)
699
699
$ output = '' ;
700
700
$ tokens = token_get_all ($ source );
701
701
$ ignoreSpace = false ;
702
- for (reset ($ tokens ); false !== $ token = current ($ tokens ); next ($ tokens )) {
703
- if (is_string ($ token )) {
702
+ for ($ i = 0 ; isset ($ tokens [$ i ]); ++$ i ) {
703
+ $ token = $ tokens [$ i ];
704
+ if (!isset ($ token [1 ]) || 'b" ' === $ token ) {
704
705
$ rawChunk .= $ token ;
705
706
} elseif (T_START_HEREDOC === $ token [0 ]) {
706
707
$ output .= $ rawChunk .$ token [1 ];
707
708
do {
708
- $ token = next ( $ tokens) ;
709
- $ output .= $ token [1 ];
709
+ $ token = $ tokens[++ $ i ] ;
710
+ $ output .= isset ( $ token [1 ]) && ' b" ' !== $ token ? $ token [ 1 ] : $ token ;
710
711
} while ($ token [0 ] !== T_END_HEREDOC );
711
712
$ rawChunk = '' ;
712
713
} elseif (T_WHITESPACE === $ token [0 ]) {
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ public function testStripComments()
307
307
$heredoc = <<<HD
308
308
309
309
310
- Heredoc should not be modified
310
+ Heredoc should not be modified {$a[1+$b]}
311
311
312
312
313
313
HD;
@@ -343,7 +343,7 @@ public function doStuff()
343
343
$heredoc = <<<HD
344
344
345
345
346
- Heredoc should not be modified
346
+ Heredoc should not be modified {$a[1+$b]}
347
347
348
348
349
349
HD;
You can’t perform that action at this time.
0 commit comments