Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/view/src/Elements/ViewComponentElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function compile(): string
->prepend(
// Open the current scope
sprintf(
'<?php (function ($attributes, $slots, $scopedVariables %s %s) { extract($scopedVariables, EXTR_SKIP); ?>',
'<?php (function ($attributes, $slots, $scopedVariables %s %s %s) { extract($scopedVariables, EXTR_SKIP); ?>',
$this->dataAttributes->isNotEmpty() ? ', ' . $this->dataAttributes->map(fn (string $_value, string $key) => "\${$key}")->implode(', ') : '',
$this->expressionAttributes->isNotEmpty() ? ', ' . $this->expressionAttributes->map(fn (string $_value, string $key) => "\${$key}")->implode(', ') : '',
$this->scopedVariables->isNotEmpty() ? ', ' . $this->scopedVariables->map(fn (string $name) => "\${$name}")->implode(', ') : '',
Expand All @@ -150,7 +150,7 @@ public function compile(): string
->append(
// Close and call the current scope
sprintf(
'<?php })(attributes: %s, slots: %s, scopedVariables: [%s] + ($scopedVariables ?? $this->currentView?->data ?? []) %s %s) ?>',
'<?php })(attributes: %s, slots: %s, scopedVariables: [%s] + ($scopedVariables ?? $this->currentView?->data ?? []) %s %s %s) ?>',
ViewObjectExporter::export($this->viewComponentAttributes),
ViewObjectExporter::export($slots),
$this->scopedVariables->isNotEmpty()
Expand All @@ -162,6 +162,9 @@ public function compile(): string
$this->expressionAttributes->isNotEmpty()
? ', ' . $this->expressionAttributes->map(fn (mixed $value, string $key) => "{$key}: " . $value)->implode(', ')
: '',
$this->scopedVariables->isNotEmpty()
? ', ' . $this->scopedVariables->map(fn (string $name) => "{$name}: \${$name}")->implode(', ')
: '',
),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/view/src/Parser/TempestViewParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class TempestViewParser
private array $scope = [];

private ?Token $currentScope {
get => $this->scope[array_key_last($this->scope) ?? ''] ?? null;
get => array_last($this->scope);
}

public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion packages/view/src/Parser/TokenCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __debugInfo(): array

public function offsetExists(mixed $offset): bool
{
return $this->tokens[$offset] ?? false;
return isset($this->tokens[$offset]);
}

public function offsetGet(mixed $offset): mixed
Expand Down
6 changes: 5 additions & 1 deletion packages/view/src/Renderers/TempestViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ public function escape(null|string|HtmlString|Stringable $value): string
return (string) $value;
}

return htmlentities((string) $value);
return htmlentities(
string: (string) $value,
flags: ENT_QUOTES | ENT_SUBSTITUTE,
encoding: 'UTF-8',
);
}

private function validateView(View $view): void
Expand Down
2 changes: 1 addition & 1 deletion packages/view/src/Slot.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
}

public string $content {
get => base64_decode($this->content, true);
get => ($d = base64_decode($this->content, strict: true)) === false ? '' : $d;
}

public ImmutableArray $exportData {
Expand Down