Skip to content

Commit 7ec8f55

Browse files
authored
Merge pull request #705 from PHPCSStandards/feature/find-start-end-of-statement-sync-tests-with-upstream
BCFile:findStartOfStatement(): sync tests with upstream
2 parents db31b5b + ee841ad commit 7ec8f55

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Tests/BackCompat/BCFile/FindStartOfStatementTest.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ switch ($foo) {
162162
/* testInsideCaseGotoStatement */
163163
goto myLabel;
164164

165+
case 7:
166+
/* testInsideCaseFullyQualifiedDieStatement */
167+
\die(1);
168+
165169
/* testDefaultStatement */
166170
default:
167171
/* testInsideDefaultContinueStatement */

Tests/BackCompat/BCFile/FindStartOfStatementTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,8 @@ public function testFindStartInsideSwitchCaseDefaultStatements($testMarker, $tar
545545
*/
546546
public static function dataFindStartInsideSwitchCaseDefaultStatements()
547547
{
548+
$php8Names = parent::usesPhp8NameTokens();
549+
548550
return [
549551
'Case keyword should be start of case statement - case itself' => [
550552
'testMarker' => '/* testCaseStatement */',
@@ -607,16 +609,22 @@ public static function dataFindStartInsideSwitchCaseDefaultStatements()
607609
'targets' => \T_CLOSE_PARENTHESIS,
608610
'expectedTarget' => \T_THROW,
609611
],
610-
'Goto should be start for contents of the goto statement - goto label' => [
612+
'Goto should be start for contents of the goto statement - goto label' => [
611613
'testMarker' => '/* testInsideCaseGotoStatement */',
612614
'targets' => \T_STRING,
613615
'expectedTarget' => \T_GOTO,
614616
],
615-
'Goto should be start for contents of the goto statement - semicolon' => [
617+
'Goto should be start for contents of the goto statement - semicolon' => [
616618
'testMarker' => '/* testInsideCaseGotoStatement */',
617619
'targets' => \T_SEMICOLON,
618620
'expectedTarget' => \T_GOTO,
619621
],
622+
'Namespace separator for "die" should be start for contents of the die statement - close parenthesis' => [
623+
// Note: not sure if this is actually correct - should this be the open parenthesis ?
624+
'testMarker' => '/* testInsideCaseFullyQualifiedDieStatement */',
625+
'targets' => T_CLOSE_PARENTHESIS,
626+
'expectedTarget' => ($php8Names === true ? T_EXIT : T_NS_SEPARATOR),
627+
],
620628
'Default keyword should be start of default statement - default itself' => [
621629
'testMarker' => '/* testDefaultStatement */',
622630
'targets' => \T_DEFAULT,

0 commit comments

Comments
 (0)