1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-09 06:11:01 +01:00
phorge-arcanist/src/lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php
Joshua Spence 4404e66735 Improve the "inline HTML" linter rule
Summary: Improve `ArcanistInlineHTMLXHPASTLinterRule` such that it doesn't raise duplicate warnings. Also be a bit more lax with whitespace.

Test Plan: Unit tests now pass.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13896
2015-08-19 15:34:43 +10:00

36 lines
744 B
PHP

<?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;
}
if (preg_match('/^\s*$/', $html->getValue())) {
continue;
}
$this->raiseLintAtToken(
$html,
pht('PHP files must only contain PHP code.'));
break;
}
}
}