}
public function process(XHPASTNode $root) {
- $calls = $root->selectDescendantsOfTypes(array(
+ $nodes = $root->selectDescendantsOfTypes(array(
+ 'n_ARRAY_LITERAL',
'n_FUNCTION_CALL',
'n_METHOD_CALL',
+ 'n_LIST',
));
- foreach ($calls as $call) {
- $params = $call->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
+ foreach ($nodes as $node) {
+ switch ($node->getTypeName()) {
+ case 'n_ARRAY_LITERAL':
+ $params = $node->getChildOfType(0, 'n_ARRAY_VALUE_LIST');
+ break;
+
+ case 'n_FUNCTION_CALL':
+ case 'n_METHOD_CALL':
+ $params = $node->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
+ break;
+
+ case 'n_LIST':
+ $params = $node->getChildOfType(0, 'n_ASSIGNMENT_LIST');
+ break;
+
+ default:
+ throw new Exception(
+ pht("Unexpected node of type '%s'!", $node->getTypeName()));
+ }
+
$tokens = $params->getTokens();
$first = head($tokens);
if (preg_match('/^\s+$/', $leading_text)) {
$this->raiseLintAtOffset(
$first->getOffset() - strlen($leading_text),
- pht('Convention: no spaces before opening parenthesis in calls.'),
+ pht('Convention: no spaces before opening parentheses.'),
$leading_text,
'');
}
- }
- foreach ($calls as $call) {
// If the last parameter of a call is a HEREDOC, don't apply this rule.
- $params = $call
- ->getChildOfType(1, 'n_CALL_PARAMETER_LIST')
- ->getChildren();
+ $params = $params->getChildren();
if ($params) {
$last_param = last($params);
}
}
- $tokens = $call->getTokens();
+ $tokens = $node->getTokens();
$last = array_pop($tokens);
+ if ($node->getTypeName() == 'n_ARRAY_LITERAL') {
+ continue;
+ }
+
$trailing = $last->getNonsemanticTokensBefore();
$trailing_text = implode('', mpull($trailing, 'getValue'));
if (preg_match('/^\s+$/', $trailing_text)) {
$this->raiseLintAtOffset(
$last->getOffset() - strlen($trailing_text),
- pht('Convention: no spaces before closing parenthesis in calls.'),
+ pht('Convention: no spaces before closing parentheses.'),
$trailing_text,
'');
}
$ex);
}
- $include = (array)idx($spec, 'include', array());
- $exclude = (array)idx($spec, 'exclude', array());
- $paths = $this->matchPaths(
- $all_paths,
- $include,
- $exclude);
-
- $test_engine->setPaths($paths);
+ if ($all_paths) {
+ $include = (array)idx($spec, 'include', array());
+ $exclude = (array)idx($spec, 'exclude', array());
+ $paths = $this->matchPaths(
+ $all_paths,
+ $include,
+ $exclude);
+
+ $test_engine->setPaths($paths);
+ }
+
$built_test_engines[] = $test_engine;
}