Complex classes like Runtime often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Runtime, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 26 | class Runtime { |
||
| 27 | const DEBUG_ERROR_LOG = 1; |
||
| 28 | const DEBUG_ERROR_EXCEPTION = 2; |
||
| 29 | const DEBUG_TAGS = 4; |
||
| 30 | const DEBUG_TAGS_ANSI = 12; |
||
| 31 | const DEBUG_TAGS_HTML = 20; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * LightnCandy runtime method for output debug info. |
||
| 35 | * |
||
| 36 | * @param string $v expression |
||
| 37 | * @param string $f runtime function name |
||
| 38 | * @param array<string,array|string|integer> $cx render time context |
||
| 39 | * |
||
| 40 | * @expect '{{123}}' when input '123', 'miss', array('flags' => array('debug' => Runtime::DEBUG_TAGS), 'runtime' => 'LightnCandy\\Runtime'), '' |
||
| 41 | * @expect '<!--MISSED((-->{{#123}}<!--))--><!--SKIPPED--><!--MISSED((-->{{/123}}<!--))-->' when input '123', 'wi', array('flags' => array('debug' => Runtime::DEBUG_TAGS_HTML), 'runtime' => 'LightnCandy\\Runtime'), false, false, function () {return 'A';} |
||
| 42 | */ |
||
| 43 | 9 | public static function debug($v, $f, $cx) { |
|
| 75 | |||
| 76 | /** |
||
| 77 | * LightnCandy runtime method for error |
||
| 78 | * |
||
| 79 | * @param array<string,array|string|integer> $cx render time context |
||
| 80 | * @param string $err error message |
||
| 81 | * |
||
| 82 | * @throws \Exception |
||
| 83 | */ |
||
| 84 | 7 | public static function err($cx, $err) { |
|
| 93 | |||
| 94 | /** |
||
| 95 | * LightnCandy runtime method for missing data error. |
||
| 96 | * |
||
| 97 | * @param array<string,array|string|integer> $cx render time context |
||
| 98 | * @param string $v expression |
||
| 99 | */ |
||
| 100 | 5 | public static function miss($cx, $v) { |
|
| 103 | |||
| 104 | /** |
||
| 105 | * LightnCandy runtime method for variable lookup. It is slower and only be used for instance property or method detection or lambdas. |
||
| 106 | * |
||
| 107 | * @param array<string,array|string|integer> $cx render time context |
||
| 108 | * @param array<array|string|integer> $base current variable context |
||
| 109 | * @param array<string|integer> $path array of names for path |
||
| 110 | * |
||
| 111 | * @return null|string Return the value or null when not found |
||
| 112 | * |
||
| 113 | * @expect null when input array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0, 'mustlok' => 0)), 0, array('a', 'b') |
||
| 114 | * @expect 3 when input array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0), 'mustlok' => 0), array('a' => array('b' => 3)), array('a', 'b') |
||
| 115 | * @expect null when input array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0, 'mustlok' => 0)), (Object) array('a' => array('b' => 3)), array('a', 'b') |
||
| 116 | * @expect 3 when input array('scopes' => array(), 'flags' => array('prop' => 1, 'method' => 0, 'mustlok' => 0)), (Object) array('a' => array('b' => 3)), array('a', 'b') |
||
| 117 | */ |
||
| 118 | 310 | public static function v($cx, $base, $path) { |
|
| 158 | |||
| 159 | /** |
||
| 160 | * LightnCandy runtime method for {{#if var}}. |
||
| 161 | * |
||
| 162 | * @param array<string,array|string|integer> $cx render time context |
||
| 163 | * @param array<array|string|integer>|string|integer|null $v value to be tested |
||
| 164 | * @param boolean $zero include zero as true |
||
| 165 | * |
||
| 166 | * @return boolean Return true when the value is not null nor false. |
||
| 167 | * |
||
| 168 | * @expect false when input array(), null, false |
||
| 169 | * @expect false when input array(), 0, false |
||
| 170 | * @expect true when input array(), 0, true |
||
| 171 | * @expect false when input array(), false, false |
||
| 172 | * @expect true when input array(), true, false |
||
| 173 | * @expect true when input array(), 1, false |
||
| 174 | * @expect false when input array(), '', false |
||
| 175 | * @expect false when input array(), array(), false |
||
| 176 | * @expect true when input array(), array(''), false |
||
| 177 | * @expect true when input array(), array(0), false |
||
| 178 | */ |
||
| 179 | 53 | public static function ifvar($cx, $v, $zero) { |
|
| 182 | |||
| 183 | /** |
||
| 184 | * LightnCandy runtime method for {{#if var}} when {{../var}} used. |
||
| 185 | * |
||
| 186 | * @param array<string,array|string|integer> $cx render time context |
||
| 187 | * @param array<array|string|integer>|string|integer|null $v value to be tested |
||
| 188 | * @param boolean $zero include zero as true |
||
| 189 | * @param array<array|string|integer> $in input data with current scope |
||
| 190 | * @param Closure|null $truecb callback function when test result is true |
||
| 191 | * @param Closure|null $falsecb callback function when test result is false |
||
| 192 | * |
||
| 193 | * @return string The rendered string of the section |
||
| 194 | * |
||
| 195 | * @expect '' when input array('scopes' => array()), null, false, array(), null |
||
| 196 | * @expect '' when input array('scopes' => array()), null, false, array(), function () {return 'Y';} |
||
| 197 | * @expect 'Y' when input array('scopes' => array()), 1, false, array(), function () {return 'Y';} |
||
| 198 | * @expect 'N' when input array('scopes' => array()), null, false, array(), function () {return 'Y';}, function () {return 'N';} |
||
| 199 | */ |
||
| 200 | 1 | public static function ifv($cx, $v, $zero, $in, $truecb, $falsecb = null) { |
|
| 212 | |||
| 213 | /** |
||
| 214 | * LightnCandy runtime method for {{#unless var}} when {{../var}} used. |
||
| 215 | * |
||
| 216 | * @param array<string,array|string|integer> $cx render time context |
||
| 217 | * @param array<array|string|integer>|string|integer|null $var value be tested |
||
| 218 | * @param boolean $zero include zero as true |
||
| 219 | * @param array<array|string|integer>|string|integer|null $in input data with current scope |
||
| 220 | * @param Closure $truecb callback function when test result is true |
||
| 221 | * @param Closure|null $falsecb callback function when test result is false |
||
| 222 | * |
||
| 223 | * @return string Return rendered string when the value is not null nor false. |
||
| 224 | * |
||
| 225 | * @expect '' when input array('scopes' => array()), null, false, array(), null |
||
| 226 | * @expect 'Y' when input array('scopes' => array()), null, false, array(), function () {return 'Y';} |
||
| 227 | * @expect '' when input array('scopes' => array()), 1, false, array(), function () {return 'Y';} |
||
| 228 | * @expect 'Y' when input array('scopes' => array()), null, false, array(), function () {return 'Y';}, function () {return 'N';} |
||
| 229 | * @expect 'N' when input array('scopes' => array()), true, false, array(), function () {return 'Y';}, function () {return 'N';} |
||
| 230 | */ |
||
| 231 | 1 | public static function unl($cx, $var, $zero, $in, $truecb, $falsecb = null) { |
|
| 234 | |||
| 235 | /** |
||
| 236 | * LightnCandy runtime method for {{^var}} inverted section. |
||
| 237 | * |
||
| 238 | * @param array<string,array|string|integer> $cx render time context |
||
| 239 | * @param array<array|string|integer>|string|integer|null $v value to be tested |
||
| 240 | * |
||
| 241 | * @return boolean Return true when the value is not null nor false. |
||
| 242 | * |
||
| 243 | * @expect true when input array(), null |
||
| 244 | * @expect false when input array(), 0 |
||
| 245 | * @expect true when input array(), false |
||
| 246 | * @expect false when input array(), 'false' |
||
| 247 | * @expect true when input array(), array() |
||
| 248 | * @expect false when input array(), array('1') |
||
| 249 | */ |
||
| 250 | 36 | public static function isec($cx, $v) { |
|
| 253 | |||
| 254 | /** |
||
| 255 | * LightnCandy runtime method for {{{var}}} . |
||
| 256 | * |
||
| 257 | * @param array<string,array|string|integer> $cx render time context |
||
| 258 | * @param array<array|string|integer>|string|integer|null $v value to be output |
||
| 259 | * |
||
| 260 | * @return string The raw value of the specified variable |
||
| 261 | * |
||
| 262 | * @expect true when input array('flags' => array('jstrue' => 0, 'mustlam' => 0, 'lambda' => 0)), true |
||
| 263 | * @expect 'true' when input array('flags' => array('jstrue' => 1)), true |
||
| 264 | * @expect '' when input array('flags' => array('jstrue' => 0, 'mustlam' => 0, 'lambda' => 0)), false |
||
| 265 | * @expect 'false' when input array('flags' => array('jstrue' => 1)), false |
||
| 266 | * @expect 'false' when input array('flags' => array('jstrue' => 1)), false, true |
||
| 267 | * @expect 'Array' when input array('flags' => array('jstrue' => 1, 'jsobj' => 0)), array('a', 'b') |
||
| 268 | * @expect 'a,b' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a', 'b') |
||
| 269 | * @expect '[object Object]' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('a', 'c' => 'b') |
||
| 270 | * @expect '[object Object]' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('c' => 'b') |
||
| 271 | * @expect 'a,true' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a', true) |
||
| 272 | * @expect 'a,1' when input array('flags' => array('jstrue' => 0, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',true) |
||
| 273 | * @expect 'a,' when input array('flags' => array('jstrue' => 0, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',false) |
||
| 274 | * @expect 'a,false' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',false) |
||
| 275 | */ |
||
| 276 | 255 | public static function raw($cx, $v) { |
|
| 313 | |||
| 314 | /** |
||
| 315 | * LightnCandy runtime method for {{var}} . |
||
| 316 | * |
||
| 317 | * @param array<string,array|string|integer> $cx render time context |
||
| 318 | * @param array<array|string|integer>|string|integer|null $var value to be htmlencoded |
||
| 319 | * |
||
| 320 | * @return string The htmlencoded value of the specified variable |
||
| 321 | * |
||
| 322 | * @expect 'a' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a' |
||
| 323 | * @expect 'a&b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a&b' |
||
| 324 | * @expect 'a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a\'b' |
||
| 325 | */ |
||
| 326 | 44 | public static function enc($cx, $var) { |
|
| 329 | |||
| 330 | /** |
||
| 331 | * LightnCandy runtime method for {{var}} , and deal with single quote to same as handlebars.js . |
||
| 332 | * |
||
| 333 | * @param array<string,array|string|integer> $cx render time context |
||
| 334 | * @param array<array|string|integer>|string|integer|null $var value to be htmlencoded |
||
| 335 | * |
||
| 336 | * @return string The htmlencoded value of the specified variable |
||
| 337 | * |
||
| 338 | * @expect 'a' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a' |
||
| 339 | * @expect 'a&b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a&b' |
||
| 340 | * @expect 'a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a\'b' |
||
| 341 | * @expect '`a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), '`a\'b' |
||
| 342 | */ |
||
| 343 | 185 | public static function encq($cx, $var) { |
|
| 346 | |||
| 347 | /** |
||
| 348 | * LightnCandy runtime method for {{#var}} section. |
||
| 349 | * |
||
| 350 | * @param array<string,array|string|integer> $cx render time context |
||
| 351 | * @param array<array|string|integer>|string|integer|null $v value for the section |
||
| 352 | * @param array<array|string|integer>|string|integer|null $in input data with current scope |
||
| 353 | * @param boolean $each true when rendering #each |
||
| 354 | * @param Closure $cb callback function to render child context |
||
| 355 | * @param Closure|null $else callback function to render child context when {{else}} |
||
| 356 | * |
||
| 357 | * @return string The rendered string of the section |
||
| 358 | * |
||
| 359 | * @expect '' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), false, false, false, function () {return 'A';} |
||
| 360 | * @expect '' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), null, null, false, function () {return 'A';} |
||
| 361 | * @expect 'A' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), true, true, false, function () {return 'A';} |
||
| 362 | * @expect 'A' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 0, 0, false, function () {return 'A';} |
||
| 363 | * @expect '-a=' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array('a'), array('a'), false, function ($c, $i) {return "-$i=";} |
||
| 364 | * @expect '-a=-b=' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array('a','b'), array('a','b'), false, function ($c, $i) {return "-$i=";} |
||
| 365 | * @expect '' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 'abc', 'abc', true, function ($c, $i) {return "-$i=";} |
||
| 366 | * @expect '-b=' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array('a' => 'b'), array('a' => 'b'), true, function ($c, $i) {return "-$i=";} |
||
| 367 | * @expect '1' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 'b', 'b', false, function ($c, $i) {return count($i);} |
||
| 368 | * @expect '1' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 1, 1, false, function ($c, $i) {return print_r($i, true);} |
||
| 369 | * @expect '0' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 0, 0, false, function ($c, $i) {return print_r($i, true);} |
||
| 370 | * @expect '{"b":"c"}' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array('b' => 'c'), array('b' => 'c'), false, function ($c, $i) {return json_encode($i);} |
||
| 371 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array(), 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 372 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array(), 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 373 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), false, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 374 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), false, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 375 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), '', 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 376 | * @expect 'cb' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), '', 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 377 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 0, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 378 | * @expect 'cb' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 0, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 379 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), new stdClass, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 380 | * @expect 'cb' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), new stdClass, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 381 | * @expect '268' when input array('flags' => array('spvar' => 1, 'mustlam' => 0, 'lambda' => 0), 'sp_vars'=>array('root' => 0)), array(1,3,4), 0, false, function ($c, $i) {return $i * 2;} |
||
| 382 | * @expect '038' when input array('flags' => array('spvar' => 1, 'mustlam' => 0, 'lambda' => 0), 'sp_vars'=>array('root' => 0)), array(1,3,'a'=>4), 0, true, function ($c, $i) {return $i * $c['sp_vars']['index'];} |
||
| 383 | */ |
||
| 384 | 142 | public static function sec($cx, $v, $in, $each, $cb, $else = null) { |
|
| 500 | |||
| 501 | /** |
||
| 502 | * LightnCandy runtime method for {{#with var}} . |
||
| 503 | * |
||
| 504 | * @param array<string,array|string|integer> $cx render time context |
||
| 505 | * @param array<array|string|integer>|string|integer|null $v value to be the new context |
||
| 506 | * @param array<array|string|integer>|string|integer|null $in input data with current scope |
||
| 507 | * @param Closure $cb callback function to render child context |
||
| 508 | * @param Closure|null $else callback function to render child context when {{else}} |
||
| 509 | * |
||
| 510 | * @return string The rendered string of the token |
||
| 511 | * |
||
| 512 | * @expect '' when input array(), false, false, function () {return 'A';} |
||
| 513 | * @expect '' when input array(), null, null, function () {return 'A';} |
||
| 514 | * @expect '{"a":"b"}' when input array(), array('a'=>'b'), array('a'=>'c'), function ($c, $i) {return json_encode($i);} |
||
| 515 | * @expect '-b=' when input array(), 'b', array('a'=>'b'), function ($c, $i) {return "-$i=";} |
||
| 516 | */ |
||
| 517 | 13 | public static function wi($cx, $v, $in, $cb, $else = null) { |
|
| 526 | |||
| 527 | /** |
||
| 528 | * LightnCandy runtime method for {{> partial}} . |
||
| 529 | * |
||
| 530 | * @param array<string,array|string|integer> $cx render time context |
||
| 531 | * @param string $p partial name |
||
| 532 | * @param array<array|string|integer>|string|integer|null $v value to be the new context |
||
| 533 | * |
||
| 534 | * @return string The rendered string of the partial |
||
| 535 | * |
||
| 536 | */ |
||
| 537 | 52 | public static function p($cx, $p, $v, $sp = '') { |
|
| 552 | |||
| 553 | /** |
||
| 554 | * LightnCandy runtime method for custom helpers. |
||
| 555 | * |
||
| 556 | * @param array<string,array|string|integer> $cx render time context |
||
| 557 | * @param string $ch the name of custom helper to be executed |
||
| 558 | * @param array<array> $vars variables for the helper |
||
| 559 | * @param string $op the name of variable resolver. should be one of: 'raw', 'enc', or 'encq'. |
||
| 560 | * |
||
| 561 | * @return string The rendered string of the token |
||
| 562 | * |
||
| 563 | * @expect '---' when input array('helpers' => array('a' => function ($i) {return "-$i[0]-";})), 'a', array(array('-'),array()), 'raw' |
||
| 564 | * @expect '-&-' when input array('helpers' => array('a' => function ($i) {return "-$i[0]-";})), 'a', array(array('&'),array()), 'enc' |
||
| 565 | * @expect '-'-' when input array('helpers' => array('a' => function ($i) {return "-$i[0]-";})), 'a', array(array('\''),array()), 'encq' |
||
| 566 | * @expect '-b-' when input array('helpers' => array('a' => function ($i,$j) {return "-{$j['a']}-";})), 'a', array(array(),array('a' => 'b')), 'raw' |
||
| 567 | */ |
||
| 568 | 22 | public static function ch($cx, $ch, $vars, $op) { |
|
| 571 | |||
| 572 | /** |
||
| 573 | * LightnCandy runtime method to handle response of custom helpers. |
||
| 574 | * |
||
| 575 | * @param string|array<string,array|string|integer> $ret return value from custom helper |
||
| 576 | * @param string $op the name of variable resolver. should be one of: 'raw', 'enc', or 'encq'. |
||
| 577 | * |
||
| 578 | * @return string The rendered string of the token |
||
| 579 | * |
||
| 580 | * @expect '-&-' when input '-&-', 'raw' |
||
| 581 | * @expect '-&'-' when input '-&\'-', 'enc' |
||
| 582 | * @expect '-&'-' when input '-&\'-', 'encq' |
||
| 583 | * @expect '-&'-' when input array('-&\'-'), 'enc' |
||
| 584 | * @expect '-&'-' when input array('-&\'-'), 'encq' |
||
| 585 | * @expect '-&-' when input array('-&-', false), 'enc' |
||
| 586 | * @expect '-&-' when input array('-&-', false), 'raw' |
||
| 587 | * @expect '-&-' when input array('-&-', 'raw'), 'enc' |
||
| 588 | * @expect '-&'-' when input array('-&\'-', 'encq'), 'raw' |
||
| 589 | */ |
||
| 590 | 127 | public static function chret($ret, $op) { |
|
| 606 | |||
| 607 | /** |
||
| 608 | * LightnCandy runtime method for Handlebars.js style custom helpers. |
||
| 609 | * |
||
| 610 | * @param array<string,array|string|integer> $cx render time context |
||
| 611 | * @param string $ch the name of custom helper to be executed |
||
| 612 | * @param array<array|string|integer>|string|integer|null $vars variables for the helper |
||
| 613 | * @param string $op the name of variable resolver. should be one of: 'raw', 'enc', or 'encq'. |
||
| 614 | * @param boolean $inverted the logic will be inverted |
||
| 615 | * @param Closure|null $cb callback function to render child context |
||
| 616 | * @param Closure|null $else callback function to render child context when {{else}} |
||
| 617 | * |
||
| 618 | * @return string The rendered string of the token |
||
| 619 | */ |
||
| 620 | 107 | public static function hbch($cx, $ch, $vars, $op, $inverted, $cb = null, $else = null) { |
|
| 696 | |||
| 697 | /** |
||
| 698 | * LightnCandy runtime method for block custom helpers. |
||
| 699 | * |
||
| 700 | * @param array<string,array|string|integer> $cx render time context |
||
| 701 | * @param string $ch the name of custom helper to be executed |
||
| 702 | * @param array<array|string|integer>|string|integer|null $vars variables for the helper |
||
| 703 | * @param array<array|string|integer>|string|integer|null $in input data with current scope |
||
| 704 | * @param boolean $inverted the logic will be inverted |
||
| 705 | * @param Closure $cb callback function to render child context |
||
| 706 | * @param Closure|null $else callback function to render child context when {{else}} |
||
| 707 | * |
||
| 708 | * @return string The rendered string of the token |
||
| 709 | * |
||
| 710 | * @expect '4.2.3' when input array('blockhelpers' => array('a' => function ($cx) {return array($cx,2,3);})), 'a', array(0, 0), 4, false, function($cx, $i) {return implode('.', $i);} |
||
| 711 | * @expect '2.6.5' when input array('blockhelpers' => array('a' => function ($cx,$in) {return array($cx,$in[0],5);})), 'a', array('6', 0), 2, false, function($cx, $i) {return implode('.', $i);} |
||
| 712 | * @expect '' when input array('blockhelpers' => array('a' => function ($cx,$in) {})), 'a', array('6', 0), 2, false, function($cx, $i) {return implode('.', $i);} |
||
| 713 | */ |
||
| 714 | 4 | public static function bch($cx, $ch, $vars, $in, $inverted, $cb, $else = null) { |
|
| 741 | } |
||
| 742 | |||
| 743 |