From 702e8896e27882d57ba4e551092b5bd442f8acb7 Mon Sep 17 00:00:00 2001 From: Michel Bardelmeijer Date: Wed, 27 Sep 2023 17:14:07 +0200 Subject: [PATCH] Codestyle --- src/LivewireExtension.php | 4 ++-- src/LivewireTokenParser.php | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/LivewireExtension.php b/src/LivewireExtension.php index e579353..2db94ce 100644 --- a/src/LivewireExtension.php +++ b/src/LivewireExtension.php @@ -2,11 +2,10 @@ namespace Enflow\LivewireTwig; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\Blade; +use Livewire\Mechanisms\FrontendAssets\FrontendAssets; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -use Livewire\Mechanisms\FrontendAssets\FrontendAssets; class LivewireExtension extends AbstractExtension { @@ -16,6 +15,7 @@ public function callDirective(string $directive, array $args = []): string $call = $directives[$directive] ?? null; $r = call_user_func_array($call, $args); + return "?> $r function () use ($stream, $lineno) { $stream->expect(Token::BLOCK_END_TYPE); // Expect the end block + return new ThisNode([], [], $lineno, $this->getTag()); }, @@ -55,7 +56,7 @@ public function parse(Token $token) $stream->expect(Token::BLOCK_END_TYPE); // Parse the body until the 'endpersist' tag. - $body = $this->parser->subparse(fn(Token $token) => $token->test('livewire'), true); + $body = $this->parser->subparse(fn (Token $token) => $token->test('livewire'), true); // Now, since we know we're at a 'livewire.' token, we should expect the 'endpersist' after it. $stream->expect(Token::PUNCTUATION_TYPE, '.'); @@ -93,10 +94,11 @@ public function parse(Token $token) $stream->expect(Token::BLOCK_END_TYPE); // Expect the end block $attrs = ['variables' => $variables, 'key' => $key]; + return new LivewireNode($component, $attrs, $lineno, $this->getTag()); }, - default => fn() => throw new SyntaxError(sprintf('Unexpected token after "livewire.". Expected %s but got "%s".', implode(' or ', $this->types), $type), $lineno, $stream->getSourceContext()), + default => fn () => throw new SyntaxError(sprintf('Unexpected token after "livewire.". Expected %s but got "%s".', implode(' or ', $this->types), $type), $lineno, $stream->getSourceContext()), })(); } @@ -104,4 +106,4 @@ public function getTag(): string { return 'livewire'; } -} \ No newline at end of file +}