diff --git a/Tests/BackCompat/BCFile/GetMethodParametersTest.inc b/Tests/BackCompat/BCFile/GetMethodParametersTest.inc index 2b10507b..ac374447 100644 --- a/Tests/BackCompat/BCFile/GetMethodParametersTest.inc +++ b/Tests/BackCompat/BCFile/GetMethodParametersTest.inc @@ -312,6 +312,9 @@ function() use() {}; /* testClosureUse */ function() use( $foo, $bar ) {}; +/* testClosureUseWithReference */ +$cl = function() use (&$foo, &$bar) {}; + /* testFunctionParamListWithTrailingComma */ function trailingComma( ?string $foo /*comment*/ , diff --git a/Tests/BackCompat/BCFile/GetMethodParametersTest.php b/Tests/BackCompat/BCFile/GetMethodParametersTest.php index 23bb25e5..9fb1d1de 100644 --- a/Tests/BackCompat/BCFile/GetMethodParametersTest.php +++ b/Tests/BackCompat/BCFile/GetMethodParametersTest.php @@ -2826,6 +2826,49 @@ public function testClosureUse() $this->getMethodParametersTestHelper('/* ' . __FUNCTION__ . ' */', $expected, [T_USE]); } + /** + * Verify handling of a closure T_USE token with variables imported by reference. + * + * @return void + */ + public function testClosureUseWithReference() + { + // Offsets are relative to the T_USE token. + $expected = []; + $expected[0] = [ + 'token' => 4, + 'name' => '$foo', + 'content' => '&$foo', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 3, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => 5, + ]; + $expected[1] = [ + 'token' => 8, + 'name' => '$bar', + 'content' => '&$bar', + 'has_attributes' => false, + 'pass_by_reference' => true, + 'reference_token' => 7, + 'variable_length' => false, + 'variadic_token' => false, + 'type_hint' => '', + 'type_hint_token' => false, + 'type_hint_end_token' => false, + 'nullable_type' => false, + 'comma_token' => false, + ]; + + $this->getMethodParametersTestHelper('/* ' . __FUNCTION__ . ' */', $expected, [T_USE]); + } + /** * Verify function declarations with trailing commas are handled correctly. *