Page MenuHomePhabricator

D17825.id42871.diff
No OneTemporary

D17825.id42871.diff

diff --git a/src/lint/linter/xhpast/rules/ArcanistDefaultParametersXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistDefaultParametersXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistDefaultParametersXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistDefaultParametersXHPASTLinterRule.php
@@ -24,10 +24,12 @@
foreach ($parameters as $parameter) {
$default_value = $parameter->getChildByIndex(2);
+ $is_variadic_argument =
+ $parameter->getChildByIndex(1)->getTypeName() === 'n_UNPACK';
if ($default_value->getTypeName() != 'n_EMPTY') {
$default_found = true;
- } else if ($default_found) {
+ } else if (!$is_variadic_argument && $default_found) {
$this->raiseLintAtNode(
$parameter_list,
pht(
diff --git a/src/lint/linter/xhpast/rules/__tests__/default-parameters/default-parameters.lint-test b/src/lint/linter/xhpast/rules/__tests__/default-parameters/default-parameters.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/default-parameters/default-parameters.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/default-parameters/default-parameters.lint-test
@@ -7,6 +7,8 @@
class MyClass {
public function myMethod($x, $y = null, $z) {}
}
+
+function variadic_fun($x, $y = null, ...$params) {}
~~~~~~~~~~
warning:4:13
warning:8:27

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 29, 11:10 PM (6 d, 17 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6753918
Default Alt Text
D17825.id42871.diff (1 KB)

Event Timeline