From ee841aded5c59520a80677c31af1f62e7adcdaed Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Aug 2025 18:37:27 +0200 Subject: [PATCH] BCFile:findStartOfStatement(): sync tests with upstream Ref: PHPCSStandards/PHP_CodeSniffer 1206 --- Tests/BackCompat/BCFile/FindStartOfStatementTest.inc | 4 ++++ Tests/BackCompat/BCFile/FindStartOfStatementTest.php | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Tests/BackCompat/BCFile/FindStartOfStatementTest.inc b/Tests/BackCompat/BCFile/FindStartOfStatementTest.inc index 5b601075..681289ef 100644 --- a/Tests/BackCompat/BCFile/FindStartOfStatementTest.inc +++ b/Tests/BackCompat/BCFile/FindStartOfStatementTest.inc @@ -162,6 +162,10 @@ switch ($foo) { /* testInsideCaseGotoStatement */ goto myLabel; + case 7: + /* testInsideCaseFullyQualifiedDieStatement */ + \die(1); + /* testDefaultStatement */ default: /* testInsideDefaultContinueStatement */ diff --git a/Tests/BackCompat/BCFile/FindStartOfStatementTest.php b/Tests/BackCompat/BCFile/FindStartOfStatementTest.php index 9eb39160..5fb1bf54 100644 --- a/Tests/BackCompat/BCFile/FindStartOfStatementTest.php +++ b/Tests/BackCompat/BCFile/FindStartOfStatementTest.php @@ -545,6 +545,8 @@ public function testFindStartInsideSwitchCaseDefaultStatements($testMarker, $tar */ public static function dataFindStartInsideSwitchCaseDefaultStatements() { + $php8Names = parent::usesPhp8NameTokens(); + return [ 'Case keyword should be start of case statement - case itself' => [ 'testMarker' => '/* testCaseStatement */', @@ -607,16 +609,22 @@ public static function dataFindStartInsideSwitchCaseDefaultStatements() 'targets' => \T_CLOSE_PARENTHESIS, 'expectedTarget' => \T_THROW, ], - 'Goto should be start for contents of the goto statement - goto label' => [ + 'Goto should be start for contents of the goto statement - goto label' => [ 'testMarker' => '/* testInsideCaseGotoStatement */', 'targets' => \T_STRING, 'expectedTarget' => \T_GOTO, ], - 'Goto should be start for contents of the goto statement - semicolon' => [ + 'Goto should be start for contents of the goto statement - semicolon' => [ 'testMarker' => '/* testInsideCaseGotoStatement */', 'targets' => \T_SEMICOLON, 'expectedTarget' => \T_GOTO, ], + 'Namespace separator for "die" should be start for contents of the die statement - close parenthesis' => [ + // Note: not sure if this is actually correct - should this be the open parenthesis ? + 'testMarker' => '/* testInsideCaseFullyQualifiedDieStatement */', + 'targets' => T_CLOSE_PARENTHESIS, + 'expectedTarget' => ($php8Names === true ? T_EXIT : T_NS_SEPARATOR), + ], 'Default keyword should be start of default statement - default itself' => [ 'testMarker' => '/* testDefaultStatement */', 'targets' => \T_DEFAULT,