Skip to content

Commit

Permalink
Fix not-whitespace HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 29, 2020
1 parent 6905d66 commit f61f3f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rules/Whitespace/FileWhitespaceRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getLastNodes(): array
$lastNodes[] = $nodes[count($nodes) - 1];
}
foreach ($lastNodes as $lastNode) {
if (!$lastNode instanceof Node\Stmt\InlineHTML || Strings::match($lastNode->value, '#(\s+)#') === null) {
if (!$lastNode instanceof Node\Stmt\InlineHTML || Strings::match($lastNode->value, '#^(\s+)$#') === null) {
continue;
}

Expand Down
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/Whitespace/FileWhitespaceRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public function testTrailingWhitespace(): void
]);
}

public function testHtmlAfterClose(): void
{
$this->analyse([__DIR__ . '/data/html-after-close.php'], []);
}

}
7 changes: 7 additions & 0 deletions tests/PHPStan/Rules/Whitespace/data/html-after-close.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

echo 'test';

?>

<html><head>

0 comments on commit f61f3f9

Please sign in to comment.