2015-08-14 07:41:41 +10:00
|
|
|
<?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;
|
|
|
|
}
|
|
|
|
|
2015-08-19 15:34:43 +10:00
|
|
|
if (preg_match('/^\s*$/', $html->getValue())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-08-14 07:41:41 +10:00
|
|
|
$this->raiseLintAtToken(
|
|
|
|
$html,
|
|
|
|
pht('PHP files must only contain PHP code.'));
|
2015-08-19 15:34:43 +10:00
|
|
|
break;
|
2015-08-14 07:41:41 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|