Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14118480
D13871.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13871.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -125,6 +125,7 @@
'ArcanistImplicitConstructorXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php',
'ArcanistImplicitFallthroughXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistImplicitFallthroughXHPASTLinterRule.php',
'ArcanistImplicitVisibilityXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistImplicitVisibilityXHPASTLinterRule.php',
+ 'ArcanistInlineHTMLXHPASTLinterRule' => 'lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php',
'ArcanistInnerFunctionXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistInnerFunctionXHPASTLinterRule.php',
'ArcanistInstallCertificateWorkflow' => 'workflow/ArcanistInstallCertificateWorkflow.php',
'ArcanistInstanceOfOperatorXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php',
@@ -406,6 +407,7 @@
'ArcanistImplicitConstructorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistImplicitFallthroughXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistImplicitVisibilityXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
+ 'ArcanistInlineHTMLXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistInnerFunctionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistInstallCertificateWorkflow' => 'ArcanistWorkflow',
'ArcanistInstanceOfOperatorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
diff --git a/src/lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php b/src/lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php
@@ -0,0 +1,31 @@
+<?php
+
+final class ArcanistInlineHTMLXHPASTLinterRule
+ extends ArcanistXHPASTLinterRule {
+
+ const ID = 78;
+
+ public function getLintName() {
+ return pht('Inline HTML');
+ }
+
+ public function getLintSeverity() {
+ return ArcanistLintSeverity::SEVERITY_DISABLED;
+ }
+
+ public function process(XHPASTNode $root) {
+ $inline_html = $root->selectTokensOfType('T_INLINE_HTML');
+
+ foreach ($inline_html as $html) {
+ if (substr($html->getValue(), 0, 2) == '#!') {
+ // Ignore shebang lines.
+ continue;
+ }
+
+ $this->raiseLintAtToken(
+ $html,
+ pht('PHP files must only contain PHP code.'));
+ }
+ }
+
+}
diff --git a/src/lint/linter/__tests__/xhpast/inline-html.lint-test b/src/lint/linter/__tests__/xhpast/inline-html.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/__tests__/xhpast/inline-html.lint-test
@@ -0,0 +1,4 @@
+#!/usr/bin/env php
+<html>
+~~~~~~~~~~
+disabled:2:1
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 12:05 AM (11 h, 22 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6807210
Default Alt Text
D13871.diff (2 KB)
Attached To
Mode
D13871: Add a linter rule for inline HTML
Attached
Detach File
Event Timeline
Log In to Comment