Skip to content

Commit acc138d

Browse files
committed
make sure the blade file closes with a quote
1 parent b525566 commit acc138d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/Parser/Walker.php

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Contexts\Base;
66
use App\Support\Debugs;
77
use Microsoft\PhpParser\Node\SourceFileNode;
8+
use Microsoft\PhpParser\Node\Statement\InlineHtml;
89
use Microsoft\PhpParser\Parser;
910
use Microsoft\PhpParser\SkippedToken;
1011

@@ -31,6 +32,14 @@ public function __construct(protected string $document, $debug = false)
3132

3233
protected function documentSkipsClosingQuote()
3334
{
35+
if (count($this->sourceFile->statementList) === 1 && $this->sourceFile->statementList[0] instanceof InlineHtml) {
36+
// Probably Blade...
37+
$lastChar = substr($this->sourceFile->getFullText(), -1);
38+
$closesWithQuote = in_array($lastChar, ['"', "'"]);
39+
40+
return $closesWithQuote;
41+
}
42+
3443
foreach ($this->sourceFile->getDescendantNodesAndTokens() as $child) {
3544
if ($child instanceof SkippedToken && $child->getText($this->sourceFile->getFullText()) === "'") {
3645
return true;

0 commit comments

Comments
 (0)