Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistXHPASTLinter.php
| Show First 20 Lines • Show All 2,078 Lines • ▼ Show 20 Lines | foreach ($classes as $class) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * preg_quote() takes two arguments, but the second one is optional because | * preg_quote() takes two arguments, but the second one is optional because | ||||
| * it is possible to use (), [] or {} as regular expression delimiters. If | * it is possible to use (), [] or {} as regular expression delimiters. If | ||||
| * you don't pass a second argument, you're probably going to get something | * you don't pass a second argument, you're probably going to get something | ||||
| * wrong. | * wrong. | ||||
| */ | */ | ||||
| private function lintPregQuote(XHPASTNode $root) { | private function lintPregQuote(XHPASTNode $root) { | ||||
| $function_calls = $root->selectDescendantsOfType('n_FUNCTION_CALL'); | $function_calls = $root->selectDescendantsOfType('n_FUNCTION_CALL'); | ||||
| foreach ($function_calls as $call) { | foreach ($function_calls as $call) { | ||||
| $name = $call->getChildByIndex(0)->getConcreteString(); | $name = $call->getChildByIndex(0)->getConcreteString(); | ||||
| if (strtolower($name) === 'preg_quote') { | if (strtolower($name) === 'preg_quote') { | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | foreach ($binops as $binop) { | ||||
| "In PHP, '.' is the string concatenation operator, not '+'. This ". | "In PHP, '.' is the string concatenation operator, not '+'. This ". | ||||
| "expression uses '+' with a string literal as an operand."); | "expression uses '+' with a string literal as an operand."); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Finds duplicate keys in array initializers, as in | * Finds duplicate keys in array initializers, as in | ||||
| * array(1 => 'anything', 1 => 'foo'). Since the first entry is ignored, | * array(1 => 'anything', 1 => 'foo'). Since the first entry is ignored, | ||||
| * this is almost certainly an error. | * this is almost certainly an error. | ||||
| */ | */ | ||||
| private function lintDuplicateKeysInArray(XHPASTNode $root) { | private function lintDuplicateKeysInArray(XHPASTNode $root) { | ||||
| $array_literals = $root->selectDescendantsOfType('n_ARRAY_LITERAL'); | $array_literals = $root->selectDescendantsOfType('n_ARRAY_LITERAL'); | ||||
| foreach ($array_literals as $array_literal) { | foreach ($array_literals as $array_literal) { | ||||
| $nodes_by_key = array(); | $nodes_by_key = array(); | ||||
| $keys_warn = array(); | $keys_warn = array(); | ||||
| $list_node = $array_literal->getChildByIndex(0); | $list_node = $array_literal->getChildByIndex(0); | ||||
| ▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines | |||||