mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Use CaseInsensitiveArray
in ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule
Summary: Demonstrates the use of `CaseInsensitiveArray`. Depends on D14624. Test Plan: Ran unit tests. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14625
This commit is contained in:
parent
76ae02325d
commit
8ed3c45c82
1 changed files with 13 additions and 9 deletions
|
@ -14,21 +14,25 @@ final class ArcanistFunctionCallShouldBeTypeCastXHPASTLinterRule
|
|||
}
|
||||
|
||||
public function process(XHPASTNode $root) {
|
||||
static $cast_functions = array(
|
||||
'boolval' => 'bool',
|
||||
'doubleval' => 'double',
|
||||
'floatval' => 'double',
|
||||
'intval' => 'int',
|
||||
'strval' => 'string',
|
||||
);
|
||||
static $cast_functions;
|
||||
|
||||
$casts = $this->getFunctionCalls($root, array_keys($cast_functions));
|
||||
if ($cast_functions === null) {
|
||||
$cast_functions = new CaseInsensitiveArray(array(
|
||||
'boolval' => 'bool',
|
||||
'doubleval' => 'double',
|
||||
'floatval' => 'double',
|
||||
'intval' => 'int',
|
||||
'strval' => 'string',
|
||||
));
|
||||
}
|
||||
|
||||
$casts = $this->getFunctionCalls($root, $cast_functions->getKeys());
|
||||
|
||||
foreach ($casts as $cast) {
|
||||
$function_name = $cast
|
||||
->getChildOfType(0, 'n_SYMBOL_NAME')
|
||||
->getConcreteString();
|
||||
$cast_name = $cast_functions[strtolower($function_name)];
|
||||
$cast_name = $cast_functions[$function_name];
|
||||
|
||||
$parameters = $cast->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
|
||||
$replacement = null;
|
||||
|
|
Loading…
Reference in a new issue