Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14007078
D17825.id42871.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D17825.id42871.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D17825: Let default parameters linter rule support `...` in variadic function
Attached
Detach File
Event Timeline
Log In to Comment