@@ -35,7 +35,7 @@ public static function defaultHelpers(): array
3535 $ condition = $ args [0 ] instanceof Closure ? $ args [0 ]($ options ->scope ) : $ args [0 ];
3636 return static ::ifvar ($ condition , (bool ) ($ options ->hash ['includeZero ' ] ?? false ))
3737 ? $ options ->fn ($ options ->scope )
38- : $ options ->inverse ();
38+ : $ options ->inverse ($ options -> scope );
3939 },
4040 'unless ' => static function (mixed ...$ args ): string {
4141 if (count ($ args ) !== 2 ) {
@@ -45,7 +45,7 @@ public static function defaultHelpers(): array
4545 $ options = $ args [1 ];
4646 $ condition = $ args [0 ] instanceof Closure ? $ args [0 ]($ options ->scope ) : $ args [0 ];
4747 return static ::ifvar ($ condition , (bool ) ($ options ->hash ['includeZero ' ] ?? false ))
48- ? $ options ->inverse ()
48+ ? $ options ->inverse ($ options -> scope )
4949 : $ options ->fn ($ options ->scope );
5050 },
5151 'each ' => static function (mixed $ context , ?HelperOptions $ options = null ): string {
@@ -72,7 +72,7 @@ public static function defaultHelpers(): array
7272 if (static ::ifvar ($ context )) {
7373 return $ options ->fn ($ context , ['blockParams ' => [$ context ]]);
7474 }
75- return $ options ->inverse ();
75+ return $ options ->inverse ($ options -> scope );
7676 },
7777 'lookup ' => static function (mixed $ obj , string |int $ key ): mixed {
7878 if (is_array ($ obj )) {
@@ -89,12 +89,12 @@ public static function defaultHelpers(): array
8989 return '' ;
9090 },
9191 'helperMissing ' => static function (mixed ...$ args ): mixed {
92- /** @var HelperOptions $options */
93- $ options = end ($ args );
94- if (count ($ args ) === 1 && !isset ($ options ->fn )) {
92+ if (count ($ args ) === 1 ) {
9593 // Bare variable lookup with no match — return null (mirrors HBS.js undefined).
9694 return null ;
9795 }
96+ /** @var HelperOptions $options */
97+ $ options = end ($ args );
9898 throw new \Exception ('Missing helper: " ' . $ options ->name . '" ' );
9999 },
100100 'blockHelperMissing ' => static function (mixed $ context , HelperOptions $ options ): string {
@@ -105,7 +105,7 @@ public static function defaultHelpers(): array
105105 return array_is_list ($ context ) ? $ options ->iterate ($ context ) : $ options ->fn ($ context );
106106 }
107107 if ($ context === false || $ context === null ) {
108- return $ options ->inverse ();
108+ return $ options ->inverse ($ options -> scope );
109109 }
110110 // true renders with the outer scope unchanged; any other truthy value becomes the new scope.
111111 return $ options ->fn ($ context === true ? $ options ->scope : $ context );
0 commit comments