Skip to content

Commit 6238170

Browse files
committed
Remove unnecessary StringObject class
Also removed unnecessary copy of partials array.
1 parent 0790719 commit 6238170

4 files changed

Lines changed: 5 additions & 55 deletions

File tree

src/Compiler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,8 @@ private function resolveAndCompilePartial(string $name): void
710710
*/
711711
private function resolvePartial(string $name): ?string
712712
{
713-
if (isset($this->context->partials[$name])) {
714-
return $this->context->partials[$name];
713+
if (isset($this->context->options->partials[$name])) {
714+
return $this->context->options->partials[$name];
715715
}
716716
if ($this->context->options->partialResolver) {
717717
return ($this->context->options->partialResolver)($name);
@@ -737,7 +737,7 @@ public function handleDynamicPartials(): void
737737
return;
738738
}
739739

740-
foreach ($this->context->partials as $name => $code) {
740+
foreach ($this->context->options->partials as $name => $code) {
741741
$this->resolveAndCompilePartial($name);
742742
}
743743
}

src/Context.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@ final class Context
1010
/**
1111
* @param array<string, string> $usedPartial
1212
* @param array<string, string> $partialCode
13-
* @param array<string, string> $partials
1413
*/
1514
public function __construct(
1615
public readonly Options $options,
1716
public array $usedPartial = [],
1817
public array $partialCode = [],
1918
public int $usedDynPartial = 0,
20-
public array $partials = [],
21-
) {
22-
$this->partials = $options->partials;
23-
}
19+
) {}
2420
}

src/Runtime.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,7 @@ public static function merge(mixed $a, mixed $b): mixed
341341
return $b;
342342
} elseif (is_array($a)) {
343343
return array_replace($a, $b);
344-
} else {
345-
if (!is_object($a)) {
346-
$a = new StringObject($a);
347-
}
344+
} elseif (is_object($a)) {
348345
foreach ($b as $i => $v) {
349346
$a->$i = $v;
350347
}

src/StringObject.php

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)