77 */
88final class Context
99{
10+ /**
11+ * @param array<mixed> $stack
12+ * @param array<mixed>|null $currentToken
13+ * @param string[] $error
14+ * @param array<mixed> $elseLvl
15+ * @param array<string, string> $usedPartial
16+ * @param list<string> $partialStack
17+ * @param array<string, string> $partialCode
18+ * @param array<string, true> $usedHelpers
19+ * @param array<mixed> $parsed
20+ * @param array<string, string> $partials
21+ * @param array<mixed> $partialBlock
22+ * @param array<mixed> $inlinePartial
23+ * @param array<string, callable> $helpers
24+ */
1025 public function __construct (
1126 public readonly Options $ options ,
1227 public int $ level = 0 ,
@@ -15,12 +30,9 @@ public function __construct(
1530 public array $ error = [],
1631 public array $ elseLvl = [],
1732 public bool $ elseChain = false ,
18- public array $ tokens = [
19- 'ahead ' => false ,
20- 'current ' => 0 ,
21- 'count ' => 0 ,
22- 'partialind ' => '' ,
23- ],
33+ public string $ tokenSearch = '' ,
34+ public string $ partialIndent = '' ,
35+ public int |false $ tokenAhead = false ,
2436 public array $ usedPartial = [],
2537 public array $ partialStack = [],
2638 public array $ partialCode = [],
@@ -34,33 +46,17 @@ public function __construct(
3446 public array $ inlinePartial = [],
3547 public array $ helpers = [],
3648 public string |false $ rawBlock = false ,
37- public readonly array $ ops = [
38- 'separator ' => '. ' ,
39- 'f_start ' => 'return ' ,
40- 'f_end ' => '; ' ,
41- 'op_start ' => 'return ' ,
42- 'op_end ' => '; ' ,
43- 'cnd_start ' => '.( ' ,
44- 'cnd_then ' => ' ? ' ,
45- 'cnd_else ' => ' : ' ,
46- 'cnd_end ' => '). ' ,
47- 'cnd_nend ' => ') ' ,
48- ],
49+ public readonly string $ startChar = '{ ' ,
50+ public readonly string $ separator = '. ' ,
51+ public readonly string $ cndStart = '.( ' ,
52+ public readonly string $ cndEnd = '). ' ,
53+ public readonly string $ cndThen = ' ? ' ,
54+ public readonly string $ cndElse = ' : ' ,
55+ public readonly string $ fStart = 'return ' ,
56+ public readonly string $ fEnd = '; ' ,
4957 ) {
5058 $ this ->partials = $ options ->partials ;
51-
52- foreach ($ options ->helpers as $ name => $ func ) {
53- $ tn = is_int ($ name ) ? $ func : $ name ;
54- if (is_callable ($ func )) {
55- $ this ->helpers [$ tn ] = $ func ;
56- } else {
57- if (is_array ($ func )) {
58- $ this ->error [] = "Custom helper $ name must be a function, not an array. " ;
59- } else {
60- $ this ->error [] = "Custom helper ' $ tn' must be a function. " ;
61- }
62- }
63- }
59+ $ this ->helpers = $ options ->helpers ;
6460 }
6561
6662 /**
0 commit comments