From c07267e91e853aecb4ab9678f1eb4248a851892a Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 11 Mar 2025 12:09:17 -0300 Subject: [PATCH] Tests/Tokenizer: fix `conditions` checking range in `T_DEFAULT` test Among other things, the RecurseScopeMapDefaultKeywordConditionsTest ::testSwitchDefault() method checks if tokens within the scope of a `T_DEFAULT` token have `T_DEFAULT` set as one of its `conditions` array. The test was incorrectly checking token `conditions` due to an off-by-one error in the loop range when the `T_DEFAULT` uses curly braces. For a `T_DEFAULT` with curly braces, the tokenizer adds `T_DEFAULT` to the `conditions` array of all the tokens within its scope up to the `T_BREAK|T_RETURN|T_CONTINUE`, but the test was checking only until the token before the `T_BREAK|T_RETURN|T_CONTINUE`. --- .../Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php index b8ef8f689f..838982c51e 100644 --- a/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php +++ b/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php @@ -159,7 +159,7 @@ public function testSwitchDefault($testMarker, $openerOffset, $closerOffset, $co if (($opener + 1) !== $closer) { $end = $closer; if (isset($conditionStop) === true) { - $end = ($token + $conditionStop); + $end = ($token + $conditionStop + 1); } for ($i = ($opener + 1); $i < $end; $i++) {