'ArcanistPHPOpenTagXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php',
'ArcanistPHPShortTagXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistPHPShortTagXHPASTLinterRule.php',
'ArcanistParenthesesSpacingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php',
+ 'ArcanistParseStrUseXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistParseStrUseXHPASTLinterRule.php',
'ArcanistPasteWorkflow' => 'workflow/ArcanistPasteWorkflow.php',
'ArcanistPatchWorkflow' => 'workflow/ArcanistPatchWorkflow.php',
'ArcanistPhpLinter' => 'lint/linter/ArcanistPhpLinter.php',
'ArcanistPHPOpenTagXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistPHPShortTagXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistParenthesesSpacingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
+ 'ArcanistParseStrUseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistPasteWorkflow' => 'ArcanistWorkflow',
'ArcanistPatchWorkflow' => 'ArcanistWorkflow',
'ArcanistPhpLinter' => 'ArcanistExternalLinter',
--- /dev/null
+<?php
+
+final class ArcanistParseStrUseXHPASTLinterRule
+ extends ArcanistXHPASTLinterRule {
+
+ const ID = 80;
+
+ public function getLintName() {
+ return pht('Questionable Use of %s', 'parse_str()');
+ }
+
+ public function process(XHPASTNode $root) {
+ $calls = $this->getFunctionCalls($root, array('parse_str'));
+
+ foreach ($calls as $call) {
+ $call_params = $call->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
+
+ if (count($call_params->getChildren()) < 2) {
+ $this->raiseLintAtNode(
+ $call,
+ pht(
+ 'Avoid %s unless the second parameter is specified. '.
+ 'It is confusing and hinders static analysis.',
+ 'parse_str()'));
+ }
+ }
+ }
+
+}
//
// TODO: Support functions defined inside other functions which is commonly
// used with anonymous functions.
+ //
+ // TODO: parse_str() also makes lexical scope unknowable, see D13857.
$defs = $root->selectDescendantsOfTypes(array(
'n_FUNCTION_DECLARATION',