Skip to content

Commit

Permalink
Codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
mbardelmeijer committed Sep 27, 2023
1 parent 55843bd commit 702e889
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/LivewireExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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 <?php\n";
}

Expand Down
8 changes: 5 additions & 3 deletions src/LivewireTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function parse(Token $token)
return (match ($type) {
'this' => function () use ($stream, $lineno) {
$stream->expect(Token::BLOCK_END_TYPE); // Expect the end block

return new ThisNode([], [], $lineno, $this->getTag());
},

Expand All @@ -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, '.');
Expand Down Expand Up @@ -93,15 +94,16 @@ 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()),
})();
}

public function getTag(): string
{
return 'livewire';
}
}
}

0 comments on commit 702e889

Please sign in to comment.