@@ -21,10 +21,10 @@ class HelperOptions
2121 public function __construct (
2222 public mixed &$ scope ,
2323 public array &$ data ,
24+ private readonly RuntimeContext $ cx ,
2425 public readonly string $ name = '' ,
2526 public readonly array $ hash = [],
2627 public readonly int $ blockParams = 0 ,
27- private readonly ?RuntimeContext $ cx = null ,
2828 private readonly ?Closure $ cb = null ,
2929 private readonly ?Closure $ inv = null ,
3030 private readonly array $ outerBlockParams = [],
@@ -45,9 +45,10 @@ public function __isset(string $name): bool
4545
4646 public function fn (mixed $ context = Scope::Use, mixed $ data = null ): string
4747 {
48- if ($ this ->cx === null ) {
49- throw new \Exception ('fn() is not supported for inline helpers ' );
50- } elseif ($ this ->cb === null ) {
48+ if ($ this ->cb === null ) {
49+ if ($ this ->inv === null ) {
50+ throw new \Exception ('fn() is not supported for inline helpers ' );
51+ }
5152 return '' ;
5253 }
5354 $ cx = $ this ->cx ;
@@ -69,9 +70,10 @@ public function fn(mixed $context = Scope::Use, mixed $data = null): string
6970
7071 public function inverse (mixed $ context = null , mixed $ data = null ): string
7172 {
72- if ($ this ->cx === null ) {
73- throw new \Exception ('inverse() is not supported for inline helpers ' );
74- } elseif ($ this ->inv === null ) {
73+ if ($ this ->inv === null ) {
74+ if ($ this ->cb === null ) {
75+ throw new \Exception ('inverse() is not supported for inline helpers ' );
76+ }
7577 return '' ;
7678 }
7779 return $ this ->callBlock ($ this ->inv , $ context ?? $ this ->scope , $ context !== null , $ data );
@@ -81,7 +83,6 @@ public function inverse(mixed $context = null, mixed $data = null): string
8183 private function callBlock (\Closure $ closure , mixed $ context , bool $ pushDepths , ?array $ data ): string
8284 {
8385 $ cx = $ this ->cx ;
84- assert ($ cx !== null );
8586 $ savedFrame = null ;
8687 $ bpStack = null ;
8788
@@ -133,7 +134,6 @@ public function iterate(array $items): string
133134 return '' ;
134135 }
135136 $ cx = $ this ->cx ;
136- assert ($ cx !== null );
137137 $ cb = $ this ->cb ;
138138
139139 // Push depths and save partials once for the entire loop.
0 commit comments