File tree Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
3030 -- Thanks to Alessandro Chitolina for the patch
3131 -- Thanks to Juliette Reinders Folmer for the tests
3232 - Fixed bug #3296 : PSR2.ControlStructures.SwitchDeclaration takes phpcs:ignore as content of case body
33+ - Fixed bug #3303 : findStartOfStatement() doesn't work with T_OPEN_TAG_WITH_ECHO
3334 </notes>
3435 <contents>
3536 <dir name="/">
Original file line number Diff line number Diff line change @@ -2285,8 +2285,9 @@ public function findNext(
22852285 public function findStartOfStatement ($ start , $ ignore =null )
22862286 {
22872287 $ startTokens = Util \Tokens::$ blockOpeners ;
2288- $ startTokens [T_OPEN_SHORT_ARRAY ] = true ;
2289- $ startTokens [T_OPEN_TAG ] = true ;
2288+ $ startTokens [T_OPEN_SHORT_ARRAY ] = true ;
2289+ $ startTokens [T_OPEN_TAG ] = true ;
2290+ $ startTokens [T_OPEN_TAG_WITH_ECHO ] = true ;
22902291
22912292 $ endTokens = [
22922293 T_CLOSE_TAG => true ,
Original file line number Diff line number Diff line change @@ -111,3 +111,13 @@ $result = match ($key) {
111111};
112112
113113return 0 ;
114+
115+ /* testOpenTag */
116+ ?>
117+ <h1>Test</h1>
118+ <?php echo '<h2> ' , foo (), '</h2> ' ;
119+
120+ /* testOpenTagWithEcho */
121+ ?>
122+ <h1>Test</h1>
123+ <?= '<h2> ' , foo (), '</h2> ' ;
Original file line number Diff line number Diff line change @@ -468,4 +468,36 @@ public function testNestedMatch()
468468 }//end testNestedMatch()
469469
470470
471+ /**
472+ * Test nested match expressions.
473+ *
474+ * @return void
475+ */
476+ public function testOpenTag ()
477+ {
478+ $ start = $ this ->getTargetToken ('/* testOpenTag */ ' , T_OPEN_TAG );
479+ $ start += 2 ;
480+ $ found = self ::$ phpcsFile ->findStartOfStatement ($ start );
481+
482+ $ this ->assertSame (($ start - 1 ), $ found );
483+
484+ }//end testOpenTag()
485+
486+
487+ /**
488+ * Test nested match expressions.
489+ *
490+ * @return void
491+ */
492+ public function testOpenTagWithEcho ()
493+ {
494+ $ start = $ this ->getTargetToken ('/* testOpenTagWithEcho */ ' , T_OPEN_TAG_WITH_ECHO );
495+ $ start += 3 ;
496+ $ found = self ::$ phpcsFile ->findStartOfStatement ($ start );
497+
498+ $ this ->assertSame (($ start - 1 ), $ found );
499+
500+ }//end testOpenTagWithEcho()
501+
502+
471503}//end class
You can’t perform that action at this time.
0 commit comments