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">
30
30
-- Thanks to Alessandro Chitolina for the patch
31
31
-- Thanks to Juliette Reinders Folmer for the tests
32
32
- 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
33
34
</notes>
34
35
<contents>
35
36
<dir name="/">
Original file line number Diff line number Diff line change @@ -2285,8 +2285,9 @@ public function findNext(
2285
2285
public function findStartOfStatement ($ start , $ ignore =null )
2286
2286
{
2287
2287
$ 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 ;
2290
2291
2291
2292
$ endTokens = [
2292
2293
T_CLOSE_TAG => true ,
Original file line number Diff line number Diff line change @@ -111,3 +111,13 @@ $result = match ($key) {
111
111
};
112
112
113
113
return 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()
468
468
}//end testNestedMatch()
469
469
470
470
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
+
471
503
}//end class
You can’t perform that action at this time.
0 commit comments