Skip to content

Commit 7905e6d

Browse files
committed
feat: support attributes on function parameters
1 parent 01bbd7f commit 7905e6d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

file.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,17 @@ public function &get_functions() {
427427
continue;
428428
}
429429
}
430+
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
431+
// T_ATTRIBUTE introduced in PHP 8.0.
432+
if ($argtokens[$j][0] === T_ATTRIBUTE) {
433+
[, $attrclose] = $this->find_tag_pair_inlist($argtokens, $j, "#[", "]");
434+
if ($attrclose) {
435+
// Skip the attribute.
436+
$j = $attrclose;
437+
}
438+
continue;
439+
}
440+
}
430441
switch ($argtokens[$j][0]) {
431442
// Skip any whitespace, or argument visibility.
432443
case T_COMMENT:

tests/fixtures/phpdoc_method_multiline.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,17 @@ public function function_multiline5(
9696
): array {
9797
// Do something.
9898
}
99+
100+
/**
101+
* One function, what else.
102+
*
103+
* @param string $arg
104+
* @return array
105+
*/
106+
public function function_attribute(
107+
#[some_attr]
108+
string $arg
109+
): array {
110+
// Do something.
111+
}
99112
}

0 commit comments

Comments
 (0)