Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14588517
D14460.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D14460.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 12:04 PM (5 h, 38 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6978764
Default Alt Text
D14460.diff (4 KB)
Attached To
Mode
D14460: Provide more context to naming hook linter
Attached
Detach File
Event Timeline
Log In to Comment