Skip to content

Commit

Permalink
File::getMethodParameters(): add test documenting behaviour for comments
Browse files Browse the repository at this point in the history
This test demonstrates and documents the existing behaviour of the method when comments are encountered within a parameter declaration.
  • Loading branch information
jrfnl committed Apr 23, 2021
1 parent ba54cb5 commit e4af9dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/Core/File/GetMethodParametersTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ abstract class ConstructorPropertyPromotionAbstractMethod {
// 3. The callable type is not supported for properties, but that's not the concern of this method.
abstract public function __construct(public callable $y, private ...$x);
}

/* testCommentsInParameter */
function commentsInParams(
// Leading comment.
?MyClass /*-*/ & /*-*/.../*-*/ $param /*-*/ = /*-*/ 'default value' . /*-*/ 'second part' // Trailing comment.
) {}
23 changes: 23 additions & 0 deletions tests/Core/File/GetMethodParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,29 @@ public function testPHP8ConstructorPropertyPromotionAbstractMethod()
}//end testPHP8ConstructorPropertyPromotionAbstractMethod()


/**
* Verify and document behaviour when there are comments within a parameter declaration.
*
* @return void
*/
public function testCommentsInParameter()
{
$expected = [];
$expected[0] = [
'name' => '$param',
'content' => '// Leading comment.
?MyClass /*-*/ & /*-*/.../*-*/ $param /*-*/ = /*-*/ \'default value\' . /*-*/ \'second part\' // Trailing comment.',
'pass_by_reference' => true,
'variable_length' => true,
'type_hint' => '?MyClass',
'nullable_type' => true,
];

$this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected);

}//end testCommentsInParameter()


/**
* Test helper.
*
Expand Down

0 comments on commit e4af9dc

Please sign in to comment.