Skip to content

Commit 12a517b

Browse files
committed
Remove context argument from partialResolver closure
This is an internal class which shouldn't be part of the public API.
1 parent 322e797 commit 12a517b

4 files changed

Lines changed: 5 additions & 11 deletions

File tree

‎src/Compiler.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,8 @@ private function resolvePartial(string &$name): ?string
676676
if (isset($this->context->partials[$name])) {
677677
return $this->context->partials[$name];
678678
}
679-
if ($this->context->partialResolver) {
680-
return ($this->context->partialResolver)($this->context, $name);
679+
if ($this->context->options->partialResolver) {
680+
return ($this->context->options->partialResolver)($name);
681681
}
682682
return null;
683683
}

‎src/Context.php‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace DevTheorem\Handlebars;
44

5-
use Closure;
6-
75
/**
86
* @internal
97
*/
@@ -13,7 +11,6 @@ final class Context
1311
* @param array<string, string> $usedPartial
1412
* @param array<string, string> $partialCode
1513
* @param array<string, string> $partials
16-
* @param null|Closure(Context, string):(string|null) $partialResolver
1714
* @param array<mixed> $partialBlock
1815
* @param array<mixed> $inlinePartial
1916
*/
@@ -25,18 +22,16 @@ public function __construct(
2522
public int $usedPBlock = 0,
2623
public int $partialBlockId = 0,
2724
public array $partials = [],
28-
public ?Closure $partialResolver = null,
2925
public array $partialBlock = [],
3026
public array $inlinePartial = [],
3127
) {
3228
$this->partials = $options->partials;
33-
$this->partialResolver = $options->partialResolver;
3429
}
3530

3631
/**
3732
* Update from another context.
3833
*/
39-
public function merge(Context $context): void
34+
public function merge(self $context): void
4035
{
4136
$this->partials = $context->partials;
4237
$this->partialCode = $context->partialCode;

‎src/Options.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* @param array<string, bool> $knownHelpers
1414
* @param array<string, string> $partials
15-
* @param null|Closure(Context, string):(string|null) $partialResolver
15+
* @param null|Closure(string):(string|null) $partialResolver
1616
*/
1717
public function __construct(
1818
array $knownHelpers = [],

‎tests/RegressionTest.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace DevTheorem\Handlebars\Test;
44

5-
use DevTheorem\Handlebars\Context;
65
use DevTheorem\Handlebars\Handlebars;
76
use DevTheorem\Handlebars\HelperOptions;
87
use DevTheorem\Handlebars\Options;
@@ -2183,7 +2182,7 @@ public static function issueProvider(): array
21832182
[
21842183
'template' => '{{>foo}} and {{>bar}}',
21852184
'options' => new Options(
2186-
partialResolver: function (Context $context, string $name) {
2185+
partialResolver: function (string $name) {
21872186
return "PARTIAL: $name";
21882187
},
21892188
),

0 commit comments

Comments
 (0)