Summary:
Improve `ArcanistUselessOverridingMethodXHPASTLinterRule` by allowing overriding methods which set default values. For example, the following scenario is perfectly valid:
```lang=php
class SomeClass {
public function __construct($x) {}
}
class SomeOtherClass extends Class {
public function __construct($x = null) {
parent::__construct($x);
}
}
```
Test Plan: Added test case.
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: Korvin
Differential Revision: https://secure.phabricator.com/D13840
public function anotherMethod($x, &$y) {
return parent::anotherMethod($x, $y);
}
+
+ public function usefulMethodWithDefaultValue($x = null) {
+ return parent::usefulMethodWithDefaultValue($x);
+ }
}
~~~~~~~~~~
error:3:13
$parameters = array();
foreach ($parameter_list->getChildren() as $parameter) {
+ $default = $parameter->getChildByIndex(2);
$parameter = $parameter->getChildByIndex(1);
if ($parameter->getTypeName() == 'n_VARIABLE_REFERENCE') {
$parameter = $parameter->getChildOfType(0, 'n_VARIABLE');
}
+ if ($default->getTypeName() != 'n_EMPTY') {
+ continue 2;
+ }
+
$parameters[] = $parameter->getConcreteString();
}