@@ -14,7 +14,7 @@ final class Runtime
1414 */
1515 public static function miss (string $ v ): void
1616 {
17- throw new \Exception (" Runtime: $ v does not exist " );
17+ throw new \Exception (' " ' . $ v . ' " not defined ' );
1818 }
1919
2020 /**
@@ -159,14 +159,14 @@ public static function sec(RuntimeContext $cx, mixed $v, array $bp, mixed $in, b
159159 $ cx ->scopes [] = $ in ;
160160 }
161161 $ i = 0 ;
162- $ oldSpvar = $ cx ->spVars ?? [];
163- $ cx ->spVars = array_merge (['root ' => $ oldSpvar ['root ' ] ?? null ], $ oldSpvar , ['_parent ' => $ oldSpvar ]);
162+ $ oldData = $ cx ->data ?? [];
163+ $ cx ->data = array_merge (['root ' => $ oldData ['root ' ] ?? null ], $ oldData , ['_parent ' => $ oldData ]);
164164
165165 foreach ($ v as $ index => $ raw ) {
166- $ cx ->spVars ['first ' ] = ($ i === 0 );
167- $ cx ->spVars ['last ' ] = ($ i === $ last );
168- $ cx ->spVars ['key ' ] = $ index ;
169- $ cx ->spVars ['index ' ] = $ isSparseArray ? $ index : $ i ;
166+ $ cx ->data ['first ' ] = ($ i === 0 );
167+ $ cx ->data ['last ' ] = ($ i === $ last );
168+ $ cx ->data ['key ' ] = $ index ;
169+ $ cx ->data ['index ' ] = $ isSparseArray ? $ index : $ i ;
170170 $ i ++;
171171 if ($ bp ) {
172172 $ bpEntry = [];
@@ -187,11 +187,11 @@ public static function sec(RuntimeContext $cx, mixed $v, array $bp, mixed $in, b
187187 }
188188
189189 if ($ isObj ) {
190- unset($ cx ->spVars ['key ' ]);
190+ unset($ cx ->data ['key ' ]);
191191 } else {
192- unset($ cx ->spVars ['last ' ]);
192+ unset($ cx ->data ['last ' ]);
193193 }
194- unset($ cx ->spVars ['index ' ], $ cx ->spVars ['first ' ]);
194+ unset($ cx ->data ['index ' ], $ cx ->data ['first ' ]);
195195
196196 if ($ push ) {
197197 array_pop ($ cx ->scopes );
@@ -235,7 +235,7 @@ public static function sec(RuntimeContext $cx, mixed $v, array $bp, mixed $in, b
235235 },
236236 blockParams: 0 ,
237237 scope: $ in ,
238- data: $ cx ->spVars ,
238+ data: $ cx ->data ,
239239 );
240240 $ result = $ v ($ options );
241241 return static ::applyBlockHelperMissing ($ cx , $ result , $ in , $ cb , $ else );
@@ -387,7 +387,7 @@ public static function hbch(RuntimeContext $cx, string $ch, array $vars, mixed &
387387 inverse: fn () => '' ,
388388 blockParams: 0 ,
389389 scope: $ _this ,
390- data: $ cx ->spVars ,
390+ data: $ cx ->data ,
391391 );
392392
393393 return static ::exch ($ cx , $ ch , $ vars , $ options );
@@ -407,7 +407,7 @@ public static function hbch(RuntimeContext $cx, string $ch, array $vars, mixed &
407407 public static function hbbch (RuntimeContext $ cx , string $ ch , array $ vars , mixed &$ _this , bool $ inverted , \Closure $ cb , ?\Closure $ else = null , ?string $ logicalName = null ): mixed
408408 {
409409 $ blockParams = isset ($ vars [2 ]) ? count ($ vars [2 ]) : 0 ;
410- $ data = &$ cx ->spVars ;
410+ $ data = &$ cx ->data ;
411411
412412 // invert the logic
413413 if ($ inverted ) {
@@ -443,7 +443,7 @@ public static function dynhbbch(RuntimeContext $cx, string $name, mixed $callabl
443443 }
444444
445445 $ blockParams = isset ($ vars [2 ]) ? count ($ vars [2 ]) : 0 ;
446- $ data = &$ cx ->spVars ;
446+ $ data = &$ cx ->data ;
447447
448448 $ options = new HelperOptions (
449449 name: '' ,
@@ -468,7 +468,7 @@ public static function dynhbbch(RuntimeContext $cx, string $name, mixed $callabl
468468
469469 /**
470470 * Build the $fn closure passed to HelperOptions for block helpers.
471- * Handles spVars updates, block-param injection, and context scope pushing.
471+ * Handles private variable updates, block-param injection, and context scope pushing.
472472 *
473473 * @param array<array<mixed>> $vars
474474 */
@@ -480,9 +480,9 @@ private static function makeBlockFn(RuntimeContext $cx, mixed $_this, ?\Closure
480480
481481 return function ($ context = null , $ data = null ) use ($ cx , $ _this , $ cb , $ vars ) {
482482 $ cx = clone $ cx ;
483- $ old_spvar = $ cx ->spVars ;
483+ $ oldData = $ cx ->data ;
484484 if (isset ($ data ['data ' ])) {
485- $ cx ->spVars = array_merge (['root ' => $ old_spvar ['root ' ]], $ data ['data ' ], ['_parent ' => $ old_spvar ]);
485+ $ cx ->data = array_merge (['root ' => $ oldData ['root ' ]], $ data ['data ' ], ['_parent ' => $ oldData ]);
486486 }
487487
488488 if (isset ($ data ['blockParams ' ], $ vars [2 ])) {
@@ -497,7 +497,7 @@ private static function makeBlockFn(RuntimeContext $cx, mixed $_this, ?\Closure
497497 }
498498
499499 if (isset ($ data ['data ' ])) {
500- $ cx ->spVars = $ old_spvar ;
500+ $ cx ->data = $ oldData ;
501501 }
502502 return $ ret ;
503503 };
@@ -554,7 +554,7 @@ public static function exch(RuntimeContext $cx, string $ch, array $vars, HelperO
554554 try {
555555 return ($ cx ->helpers [$ ch ])(...$ args );
556556 } catch (\Throwable $ e ) {
557- throw new \Exception ("Runtime: call custom helper '$ ch' error: " . $ e ->getMessage ());
557+ throw new \Exception ("Custom helper '$ ch' error: " . $ e ->getMessage ());
558558 }
559559 }
560560}
0 commit comments