Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/Core/File/GetMethodParametersTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ function() use() {};
/* testClosureUse */
function() use( $foo, $bar ) {};

/* testClosureUseWithReference */
$cl = function() use (&$foo, &$bar) {};

/* testFunctionParamListWithTrailingComma */
function trailingComma(
?string $foo /*comment*/ ,
Expand Down
45 changes: 45 additions & 0 deletions tests/Core/File/GetMethodParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,51 @@ public function testClosureUse()
}//end testClosureUse()


/**
* 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]);

}//end testClosureUseWithReference()


/**
* Verify function declarations with trailing commas are handled correctly.
*
Expand Down