Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14016652
D17825.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.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, Nov 5, 10:23 AM (6 h, 3 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6753918
Default Alt Text
D17825.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