Page MenuHomePhabricator

D14460.id34975.diff
No OneTemporary

D14460.id34975.diff

diff --git a/src/lint/linter/xhpast/ArcanistPhutilXHPASTLintNamingHook.php b/src/lint/linter/xhpast/ArcanistPhutilXHPASTLintNamingHook.php
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/ArcanistPhutilXHPASTLintNamingHook.php
@@ -0,0 +1,11 @@
+<?php
+
+final class ArcanistPhutilXHPASTLintNamingHook
+ extends ArcanistXHPASTLintNamingHook {
+
+
+ public function lintSymbolName($type, $name, $default, array $context) {
+ //
+ }
+
+}
diff --git a/src/lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php b/src/lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php
--- a/src/lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php
+++ b/src/lint/linter/xhpast/ArcanistXHPASTLintNamingHook.php
@@ -45,15 +45,21 @@
* }
* return $default;
*
- * @param string The symbol type.
- * @param string The symbol name.
- * @param string|null The default result from the main rule engine.
- * @return string|null Null to accept the name, or a message to reject it
- * with. You should return the default value if you don't
- * want to specifically provide an override.
+ * @param string The symbol type.
+ * @param string The symbol name.
+ * @param string|null The default result from the main rule engine.
+ * @param dict<string, string> Context
+ * @return string|null Null to accept the name, or a message to
+ * reject it with. You should return the
+ * default value if you don't want to
+ * specifically provide an override.
* @task override
*/
- abstract public function lintSymbolName($type, $name, $default);
+ abstract public function lintSymbolName(
+ $type,
+ $name,
+ $default,
+ array $context);
/* -( Name Utilities )----------------------------------------------------- */
diff --git a/src/lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php
@@ -19,6 +19,7 @@
return parent::getLinterConfigurationOptions() + array(
'xhpast.naminghook' => array(
'type' => 'optional string',
+ 'default' => 'ArcanistPhutilXHPASTLintNamingHook',
'help' => pht(
'Name of a concrete subclass of %s which enforces more '.
'granular naming convention rules for symbols.',
@@ -44,23 +45,6 @@
// override us.
$names = array();
- $classes = $root->selectDescendantsOfType('n_CLASS_DECLARATION');
- foreach ($classes as $class) {
- $name_token = $class->getChildByIndex(1);
- $name_string = $name_token->getConcreteString();
-
- $names[] = array(
- 'class',
- $name_string,
- $name_token,
- ArcanistXHPASTLintNamingHook::isUpperCamelCase($name_string)
- ? null
- : pht(
- 'Follow naming conventions: classes should be named using '.
- 'UpperCamelCase.'),
- );
- }
-
$ifaces = $root->selectDescendantsOfType('n_INTERFACE_DECLARATION');
foreach ($ifaces as $iface) {
$name_token = $iface->getChildByIndex(1);
@@ -282,7 +266,7 @@
$hook_obj = newv($hook_class, array());
foreach ($names as $k => $name_attrs) {
list($type, $name, $token, $default) = $name_attrs;
- $result = $hook_obj->lintSymbolName($type, $name, $default);
+ $result = $hook_obj->lintSymbolName($type, $name, $default, $context);
$names[$k][3] = $result;
}
}
@@ -346,4 +330,23 @@
}
}
+ private function lintClassNames() {
+ $classes = $root->selectDescendantsOfType('n_CLASS_DECLARATION');
+ foreach ($classes as $class) {
+ $name_token = $class->getChildByIndex(1);
+ $name_string = $name_token->getConcreteString();
+
+ $names[] = array(
+ 'class',
+ $name_string,
+ $name_token,
+ ArcanistXHPASTLintNamingHook::isUpperCamelCase($name_string)
+ ? null
+ : pht(
+ 'Follow naming conventions: classes should be named using '.
+ 'UpperCamelCase.'),
+ );
+ }
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 9:24 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6275804
Default Alt Text
D14460.id34975.diff (4 KB)

Event Timeline