Skip to content

Commit e4af9dc

Browse files
committed
File::getMethodParameters(): add test documenting behaviour for comments
This test demonstrates and documents the existing behaviour of the method when comments are encountered within a parameter declaration.
1 parent ba54cb5 commit e4af9dc

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/Core/File/GetMethodParametersTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,9 @@ abstract class ConstructorPropertyPromotionAbstractMethod {
120120
// 3. The callable type is not supported for properties, but that's not the concern of this method.
121121
abstract public function __construct(public callable $y, private ...$x);
122122
}
123+
124+
/* testCommentsInParameter */
125+
function commentsInParams(
126+
// Leading comment.
127+
?MyClass /*-*/ & /*-*/.../*-*/ $param /*-*/ = /*-*/ 'default value' . /*-*/ 'second part' // Trailing comment.
128+
) {}

tests/Core/File/GetMethodParametersTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,29 @@ public function testPHP8ConstructorPropertyPromotionAbstractMethod()
818818
}//end testPHP8ConstructorPropertyPromotionAbstractMethod()
819819

820820

821+
/**
822+
* Verify and document behaviour when there are comments within a parameter declaration.
823+
*
824+
* @return void
825+
*/
826+
public function testCommentsInParameter()
827+
{
828+
$expected = [];
829+
$expected[0] = [
830+
'name' => '$param',
831+
'content' => '// Leading comment.
832+
?MyClass /*-*/ & /*-*/.../*-*/ $param /*-*/ = /*-*/ \'default value\' . /*-*/ \'second part\' // Trailing comment.',
833+
'pass_by_reference' => true,
834+
'variable_length' => true,
835+
'type_hint' => '?MyClass',
836+
'nullable_type' => true,
837+
];
838+
839+
$this->getMethodParametersTestHelper('/* '.__FUNCTION__.' */', $expected);
840+
841+
}//end testCommentsInParameter()
842+
843+
821844
/**
822845
* Test helper.
823846
*

0 commit comments

Comments
 (0)