From c00d8c551c81d9a91e93e85d012179d24025cf73 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 12 Sep 2013 13:01:25 -0700 Subject: [PATCH] Correct capitalization of "new" in lint Summary: Automatically correct `New` to `new` in lint. Test Plan: Ran unit tests. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6948 --- src/lint/linter/ArcanistXHPASTLinter.php | 6 ++++++ src/lint/linter/__tests__/xhpast/keyword-casing.lint-test | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 5dee2f81..896d60fd 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -2287,6 +2287,11 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { $keywords[] = head($typehint->getTokens()); } + $new_invocations = $root->selectDescendantsOfType('n_NEW'); + foreach ($new_invocations as $invocation) { + $keywords[] = head($invocation->getTokens()); + } + // NOTE: Although PHP generally allows arbitrary casing for all language // keywords, it's exceedingly rare for anyone to type, e.g., "CLASS" or // "cLaSs" in the wild. This list just attempts to cover unconventional @@ -2299,6 +2304,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { 'false' => 'false', 'null' => 'null', 'array' => 'array', + 'new' => 'new', ); foreach ($keywords as $keyword) { diff --git a/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test b/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test index 62ca7906..aa2d44dc 100644 --- a/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test +++ b/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test @@ -13,6 +13,9 @@ Array(); function f(array $x, ArRaY $y) { } + +new C(); +NeW C(); ~~~~~~~~~~ warning:6:1 warning:7:1 @@ -20,6 +23,7 @@ warning:8:1 warning:9:1 warning:11:1 warning:13:22 +warning:18:1 ~~~~~~~~~~