]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow closing tags in files containing HTML
authorJoshua Spence <josh@joshuaspence.com>
Wed, 5 Aug 2015 20:56:26 +0000 (06:56 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Wed, 5 Aug 2015 20:56:26 +0000 (06:56 +1000)
Summary: Ref T8742. PHP files which contain inline HTML should be allowed to use PHP closing tags (`?>`). This is in accordance with [[https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md | PSR-2 guidelines]].

Test Plan: Updated unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T8742

Differential Revision: https://secure.phabricator.com/D13794

src/lint/linter/__tests__/xhpast/embedded-tags.lint-test
src/lint/linter/__tests__/xhpast/php-tags-bad.lint-test
src/lint/linter/xhpast/rules/ArcanistPHPCloseTagXHPASTLinterRule.php

index b9f6be44b65d3d5a1ef9d8e0375d75920e8be4b1..d15cefb5a38653acd2867c0a5ba3f0ea33a7b63f 100644 (file)
@@ -2,4 +2,3 @@
 
 This shouldn't fatal the parser.
 ~~~~~~~~~~
-error:1:10
index e749bfa60b53f5db60e8f0df8ed288257b5c7353..7fb52e73c6d4fcfc8c6507b56c3a20603699900f 100644 (file)
@@ -4,7 +4,6 @@ garbage garbage
 ?>
 ~~~~~~~~~~
 error:1:1
-error:4:1
 ~~~~~~~~~~
 garbage garbage
 <?php
index 9a1a9db74ef045e8a87113fe139ca046127391f7..1b943b54c908b300770f36a0979e28762665d9ba 100644 (file)
@@ -10,6 +10,12 @@ final class ArcanistPHPCloseTagXHPASTLinterRule
   }
 
   public function process(XHPASTNode $root) {
+    $inline_html = $root->selectDescendantsOfType('n_INLINE_HTML');
+
+    if ($inline_html) {
+      return;
+    }
+
     foreach ($root->selectTokensOfType('T_CLOSE_TAG') as $token) {
       $this->raiseLintAtToken(
         $token,