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 | { |
||
| 28 | const DEBUG_ERROR_LOG = 1; |
||
| 29 | const DEBUG_ERROR_EXCEPTION = 2; |
||
| 30 | const DEBUG_TAGS = 4; |
||
| 31 | const DEBUG_TAGS_ANSI = 12; |
||
| 32 | const DEBUG_TAGS_HTML = 20; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * LightnCandy runtime method for output debug info. |
||
| 36 | * |
||
| 37 | * @param string $v expression |
||
| 38 | * @param string $f runtime function name |
||
| 39 | * @param array<string,array|string|integer> $cx render time context |
||
| 40 | * |
||
| 41 | * @expect '{{123}}' when input '123', 'miss', array('flags' => array('debug' => Runtime::DEBUG_TAGS), 'runtime' => 'LightnCandy\\Runtime'), '' |
||
| 42 | * @expect '<!--MISSED((-->{{#123}}<!--))--><!--SKIPPED--><!--MISSED((-->{{/123}}<!--))-->' when input '123', 'wi', array('flags' => array('debug' => Runtime::DEBUG_TAGS_HTML), 'runtime' => 'LightnCandy\\Runtime'), false, null, false, function () {return 'A';} |
||
| 43 | */ |
||
| 44 | 9 | public static function debug($v, $f, $cx) { |
|
| 74 | |||
| 75 | /** |
||
| 76 | * LightnCandy runtime method for error |
||
| 77 | * |
||
| 78 | * @param array<string,array|string|integer> $cx render time context |
||
| 79 | * @param string $err error message |
||
| 80 | * |
||
| 81 | * @throws \Exception |
||
| 82 | */ |
||
| 83 | 11 | public static function err($cx, $err) { |
|
| 92 | |||
| 93 | /** |
||
| 94 | * LightnCandy runtime method for missing data error. |
||
| 95 | * |
||
| 96 | * @param array<string,array|string|integer> $cx render time context |
||
| 97 | * @param string $v expression |
||
| 98 | */ |
||
| 99 | 5 | public static function miss($cx, $v) { |
|
| 102 | |||
| 103 | /** |
||
| 104 | * LightnCandy runtime method for variable lookup. It is slower and only be used for instance property or method detection or lambdas. |
||
| 105 | * |
||
| 106 | * @param array<string,array|string|integer> $cx render time context |
||
| 107 | * @param array|string|boolean|integer|double|null $in current context |
||
| 108 | * @param array<array|string|integer> $base current variable context |
||
| 109 | * @param array<string|integer> $path array of names for path |
||
| 110 | * @param array|null $args extra arguments for lambda |
||
| 111 | * |
||
| 112 | * @return null|string Return the value or null when not found |
||
| 113 | * |
||
| 114 | * @expect null when input array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0, 'mustlok' => 0)), null, 0, array('a', 'b') |
||
| 115 | * @expect 3 when input array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0), 'mustlok' => 0), null, array('a' => array('b' => 3)), array('a', 'b') |
||
| 116 | * @expect null when input array('scopes' => array(), 'flags' => array('prop' => 0, 'method' => 0, 'mustlok' => 0)), null, (Object) array('a' => array('b' => 3)), array('a', 'b') |
||
| 117 | * @expect 3 when input array('scopes' => array(), 'flags' => array('prop' => 1, 'method' => 0, 'mustlok' => 0)), null, (Object) array('a' => array('b' => 3)), array('a', 'b') |
||
| 118 | */ |
||
| 119 | 382 | public static function v($cx, $in, $base, $path, $args = null) { |
|
| 120 | 382 | $count = count($cx['scopes']); |
|
| 121 | 382 | while ($base) { |
|
| 122 | 346 | $v = $base; |
|
| 123 | 346 | foreach ($path as $name) { |
|
| 124 | 346 | if (is_array($v) && isset($v[$name])) { |
|
| 125 | 341 | $v = $v[$name]; |
|
| 126 | 341 | continue; |
|
| 127 | } |
||
| 128 | 33 | if (is_object($v)) { |
|
| 129 | 5 | if ($cx['flags']['prop'] && !($v instanceof \Closure) && isset($v->$name)) { |
|
| 130 | 3 | $v = $v->$name; |
|
| 131 | 3 | continue; |
|
| 132 | } |
||
| 133 | 5 | if ($cx['flags']['method'] && is_callable(array($v, $name))) { |
|
| 134 | 4 | $v = $v->$name(); |
|
| 135 | 4 | continue; |
|
| 136 | } |
||
| 137 | } |
||
| 138 | 31 | if ($cx['flags']['mustlok']) { |
|
| 139 | 28 | unset($v); |
|
| 140 | 28 | break; |
|
| 141 | } |
||
| 142 | 3 | return null; |
|
| 143 | } |
||
| 144 | 346 | if (isset($v)) { |
|
| 145 | 335 | if ($v instanceof \Closure) { |
|
| 146 | 30 | if ($cx['flags']['mustlam'] || $cx['flags']['lambda']) { |
|
| 147 | 30 | if (!$cx['flags']['knohlp'] && ($args || ($args === 0))) { |
|
| 148 | 20 | $A = $args ? $args[0] : array(); |
|
| 149 | 20 | $A[] = array('hash' => $args[1], '_this' => $in); |
|
| 150 | } else { |
||
| 151 | 11 | $A = array($in); |
|
| 152 | } |
||
| 153 | 30 | $v = call_user_func_array($v, $A); |
|
| 154 | } |
||
| 155 | } |
||
| 156 | 335 | return $v; |
|
| 157 | } |
||
| 158 | 28 | $count--; |
|
| 159 | switch ($count) { |
||
| 160 | 28 | case -1: |
|
| 161 | 27 | $base = $cx['sp_vars']['root']; |
|
| 162 | 27 | break; |
|
| 163 | 6 | case -2: |
|
| 164 | 26 | return null; |
|
| 165 | default: |
||
| 166 | 6 | $base = $cx['scopes'][$count]; |
|
| 167 | } |
||
| 168 | } |
||
| 169 | 40 | if ($args) { |
|
| 170 | 3 | static::err($cx, 'Can not find helper or lambda: "' . implode('.', $path) . '" !'); |
|
| 171 | } |
||
| 172 | 40 | } |
|
| 173 | |||
| 174 | /** |
||
| 175 | * LightnCandy runtime method for {{#if var}}. |
||
| 176 | * |
||
| 177 | * @param array<string,array|string|integer> $cx render time context |
||
| 178 | * @param array<array|string|integer>|string|integer|null $v value to be tested |
||
| 179 | * @param boolean $zero include zero as true |
||
| 180 | * |
||
| 181 | * @return boolean Return true when the value is not null nor false. |
||
| 182 | * |
||
| 183 | * @expect false when input array(), null, false |
||
| 184 | * @expect false when input array(), 0, false |
||
| 185 | * @expect true when input array(), 0, true |
||
| 186 | * @expect false when input array(), false, false |
||
| 187 | * @expect true when input array(), true, false |
||
| 188 | * @expect true when input array(), 1, false |
||
| 189 | * @expect false when input array(), '', false |
||
| 190 | * @expect false when input array(), array(), false |
||
| 191 | * @expect true when input array(), array(''), false |
||
| 192 | * @expect true when input array(), array(0), false |
||
| 193 | */ |
||
| 194 | 59 | public static function ifvar($cx, $v, $zero) { |
|
| 197 | |||
| 198 | /** |
||
| 199 | * LightnCandy runtime method for {{^var}} inverted section. |
||
| 200 | * |
||
| 201 | * @param array<string,array|string|integer> $cx render time context |
||
| 202 | * @param array<array|string|integer>|string|integer|null $v value to be tested |
||
| 203 | * |
||
| 204 | * @return boolean Return true when the value is not null nor false. |
||
| 205 | * |
||
| 206 | * @expect true when input array(), null |
||
| 207 | * @expect false when input array(), 0 |
||
| 208 | * @expect true when input array(), false |
||
| 209 | * @expect false when input array(), 'false' |
||
| 210 | * @expect true when input array(), array() |
||
| 211 | * @expect false when input array(), array('1') |
||
| 212 | */ |
||
| 213 | 37 | public static function isec($cx, $v) { |
|
| 216 | |||
| 217 | /** |
||
| 218 | * LightnCandy runtime method for {{{var}}} . |
||
| 219 | * |
||
| 220 | * @param array<string,array|string|integer> $cx render time context |
||
| 221 | * @param array<array|string|integer>|string|integer|null $v value to be output |
||
| 222 | * |
||
| 223 | * @return string The raw value of the specified variable |
||
| 224 | * |
||
| 225 | * @expect true when input array('flags' => array('jstrue' => 0, 'mustlam' => 0, 'lambda' => 0)), true |
||
| 226 | * @expect 'true' when input array('flags' => array('jstrue' => 1)), true |
||
| 227 | * @expect '' when input array('flags' => array('jstrue' => 0, 'mustlam' => 0, 'lambda' => 0)), false |
||
| 228 | * @expect 'false' when input array('flags' => array('jstrue' => 1)), false |
||
| 229 | * @expect 'false' when input array('flags' => array('jstrue' => 1)), false, true |
||
| 230 | * @expect 'Array' when input array('flags' => array('jstrue' => 1, 'jsobj' => 0)), array('a', 'b') |
||
| 231 | * @expect 'a,b' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a', 'b') |
||
| 232 | * @expect '[object Object]' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('a', 'c' => 'b') |
||
| 233 | * @expect '[object Object]' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('c' => 'b') |
||
| 234 | * @expect 'a,true' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a', true) |
||
| 235 | * @expect 'a,1' when input array('flags' => array('jstrue' => 0, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',true) |
||
| 236 | * @expect 'a,' when input array('flags' => array('jstrue' => 0, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',false) |
||
| 237 | * @expect 'a,false' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',false) |
||
| 238 | */ |
||
| 239 | 309 | public static function raw($cx, $v) { |
|
| 270 | |||
| 271 | /** |
||
| 272 | * LightnCandy runtime method for {{var}} . |
||
| 273 | * |
||
| 274 | * @param array<string,array|string|integer> $cx render time context |
||
| 275 | * @param array<array|string|integer>|string|integer|null $var value to be htmlencoded |
||
| 276 | * |
||
| 277 | * @return string The htmlencoded value of the specified variable |
||
| 278 | * |
||
| 279 | * @expect 'a' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a' |
||
| 280 | * @expect 'a&b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a&b' |
||
| 281 | * @expect 'a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a\'b' |
||
| 282 | */ |
||
| 283 | 44 | public static function enc($cx, $var) { |
|
| 286 | |||
| 287 | /** |
||
| 288 | * LightnCandy runtime method for {{var}} , and deal with single quote to same as handlebars.js . |
||
| 289 | * |
||
| 290 | * @param array<string,array|string|integer> $cx render time context |
||
| 291 | * @param array<array|string|integer>|string|integer|null $var value to be htmlencoded |
||
| 292 | * |
||
| 293 | * @return string The htmlencoded value of the specified variable |
||
| 294 | * |
||
| 295 | * @expect 'a' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a' |
||
| 296 | * @expect 'a&b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a&b' |
||
| 297 | * @expect 'a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a\'b' |
||
| 298 | * @expect '`a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), '`a\'b' |
||
| 299 | */ |
||
| 300 | 236 | public static function encq($cx, $var) { |
|
| 303 | |||
| 304 | /** |
||
| 305 | * LightnCandy runtime method for {{#var}} section. |
||
| 306 | * |
||
| 307 | * @param array<string,array|string|integer> $cx render time context |
||
| 308 | * @param array<array|string|integer>|string|integer|null $v value for the section |
||
| 309 | * @param array<string>|null $bp block parameters |
||
| 310 | * @param array<array|string|integer>|string|integer|null $in input data with current scope |
||
| 311 | * @param boolean $each true when rendering #each |
||
| 312 | * @param Closure $cb callback function to render child context |
||
| 313 | * @param Closure|null $else callback function to render child context when {{else}} |
||
| 314 | * |
||
| 315 | * @return string The rendered string of the section |
||
| 316 | * |
||
| 317 | * @expect '' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), false, null, false, false, function () {return 'A';} |
||
| 318 | * @expect '' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), null, null, null, false, function () {return 'A';} |
||
| 319 | * @expect 'A' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), true, null, true, false, function () {return 'A';} |
||
| 320 | * @expect 'A' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 0, null, 0, false, function () {return 'A';} |
||
| 321 | * @expect '-a=' when input array('scopes' => array(), 'flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array('a'), null, array('a'), false, function ($c, $i) {return "-$i=";} |
||
| 322 | * @expect '-a=-b=' when input array('scopes' => array(), 'flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array('a','b'), null, array('a','b'), false, function ($c, $i) {return "-$i=";} |
||
| 323 | * @expect '' when input array('scopes' => array(), 'flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 'abc', null, 'abc', true, function ($c, $i) {return "-$i=";} |
||
| 324 | * @expect '-b=' when input array('scopes' => array(), 'flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array('a' => 'b'), null, array('a' => 'b'), true, function ($c, $i) {return "-$i=";} |
||
| 325 | * @expect '1' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 'b', null, 'b', false, function ($c, $i) {return count($i);} |
||
| 326 | * @expect '1' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 1, null, 1, false, function ($c, $i) {return print_r($i, true);} |
||
| 327 | * @expect '0' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 0, null, 0, false, function ($c, $i) {return print_r($i, true);} |
||
| 328 | * @expect '{"b":"c"}' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array('b' => 'c'), null, array('b' => 'c'), false, function ($c, $i) {return json_encode($i);} |
||
| 329 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array(), null, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 330 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), array(), null, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 331 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), false, null, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 332 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), false, null, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 333 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), '', null, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 334 | * @expect 'cb' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), '', null, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 335 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 0, null, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 336 | * @expect 'cb' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), 0, null, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 337 | * @expect 'inv' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), new stdClass, null, 0, true, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 338 | * @expect 'cb' when input array('flags' => array('spvar' => 0, 'mustlam' => 0, 'lambda' => 0)), new stdClass, null, 0, false, function ($c, $i) {return 'cb';}, function ($c, $i) {return 'inv';} |
||
| 339 | * @expect '268' when input array('scopes' => array(), 'flags' => array('spvar' => 1, 'mustlam' => 0, 'lambda' => 0), 'sp_vars'=>array('root' => 0)), array(1,3,4), null, 0, false, function ($c, $i) {return $i * 2;} |
||
| 340 | * @expect '038' when input array('scopes' => array(), 'flags' => array('spvar' => 1, 'mustlam' => 0, 'lambda' => 0), 'sp_vars'=>array('root' => 0)), array(1,3,'a'=>4), null, 0, true, function ($c, $i) {return $i * $c['sp_vars']['index'];} |
||
| 341 | */ |
||
| 342 | 157 | public static function sec($cx, $v, $bp, $in, $each, $cb, $else = null) { |
|
| 454 | |||
| 455 | /** |
||
| 456 | * LightnCandy runtime method for {{#with var}} . |
||
| 457 | * |
||
| 458 | * @param array<string,array|string|integer> $cx render time context |
||
| 459 | * @param array<array|string|integer>|string|integer|null $v value to be the new context |
||
| 460 | * @param array<array|string|integer>|string|integer|null $in input data with current scope |
||
| 461 | * @param array<string>|null $bp block parameters |
||
| 462 | * @param Closure $cb callback function to render child context |
||
| 463 | * @param Closure|null $else callback function to render child context when {{else}} |
||
| 464 | * |
||
| 465 | * @return string The rendered string of the token |
||
| 466 | * |
||
| 467 | * @expect '' when input array(), false, null, false, function () {return 'A';} |
||
| 468 | * @expect '' when input array(), null, null, null, function () {return 'A';} |
||
| 469 | * @expect '{"a":"b"}' when input array(), array('a'=>'b'), null, array('a'=>'c'), function ($c, $i) {return json_encode($i);} |
||
| 470 | * @expect '-b=' when input array(), 'b', null, array('a'=>'b'), function ($c, $i) {return "-$i=";} |
||
| 471 | */ |
||
| 472 | 22 | public static function wi($cx, $v, $bp, $in, $cb, $else = null) { |
|
| 484 | |||
| 485 | /** |
||
| 486 | * LightnCandy runtime method to get merged context |
||
| 487 | * |
||
| 488 | * @param array<string,array|string|integer> $cx render time context |
||
| 489 | * @param array<array|string|integer>|string|integer|null $a the context to be merged |
||
| 490 | * @param array<array|string|integer>|string|integer|null $b the new context to overwrite |
||
| 491 | * |
||
| 492 | * @return array<array|string|integer>|string|integer the merged context object |
||
| 493 | * |
||
| 494 | */ |
||
| 495 | 70 | public static function m($cx, $a, $b) { |
|
| 509 | |||
| 510 | /** |
||
| 511 | * LightnCandy runtime method for {{> partial}} . |
||
| 512 | * |
||
| 513 | * @param array<string,array|string|integer> $cx render time context |
||
| 514 | * @param string $p partial name |
||
| 515 | * @param array<array|string|integer>|string|integer|null $v value to be the new context |
||
| 516 | * |
||
| 517 | * @return string The rendered string of the partial |
||
| 518 | * |
||
| 519 | */ |
||
| 520 | 65 | public static function p($cx, $p, $v, $sp = '') { |
|
| 528 | |||
| 529 | /** |
||
| 530 | * LightnCandy runtime method for {{> partial}} . |
||
| 531 | * |
||
| 532 | * @param array<string,array|string|integer> $cx render time context |
||
| 533 | * @param string $p partial name |
||
| 534 | * @param Closure $code the compiled partial code |
||
| 535 | * |
||
| 536 | * @return string The rendered string of the partial |
||
| 537 | * |
||
| 538 | */ |
||
| 539 | public static function in(&$cx, $p, $code) { |
||
| 542 | |||
| 543 | /** |
||
| 544 | 22 | * LightnCandy runtime method for custom helpers. |
|
| 545 | 22 | * |
|
| 546 | * @param array<string,array|string|integer> $cx render time context |
||
| 547 | * @param string $ch the name of custom helper to be executed |
||
| 548 | * @param array<array> $vars variables for the helper |
||
| 549 | * @param string $op the name of variable resolver. should be one of: 'raw', 'enc', or 'encq'. |
||
| 550 | * |
||
| 551 | * @return string The rendered string of the token |
||
| 552 | * |
||
| 553 | * @expect '---' when input array('helpers' => array('a' => function ($i) {return "-$i[0]-";})), 'a', array(array('-'),array()), 'raw' |
||
| 554 | * @expect '-&-' when input array('helpers' => array('a' => function ($i) {return "-$i[0]-";})), 'a', array(array('&'),array()), 'enc' |
||
| 555 | * @expect '-'-' when input array('helpers' => array('a' => function ($i) {return "-$i[0]-";})), 'a', array(array('\''),array()), 'encq' |
||
| 556 | * @expect '-b-' when input array('helpers' => array('a' => function ($i,$j) {return "-{$j['a']}-";})), 'a', array(array(),array('a' => 'b')), 'raw' |
||
| 557 | */ |
||
| 558 | public static function ch($cx, $ch, $vars, $op) { |
||
| 561 | |||
| 562 | /** |
||
| 563 | * LightnCandy runtime method to handle response of custom helpers. |
||
| 564 | * |
||
| 565 | * @param string|array<string,array|string|integer> $ret return value from custom helper |
||
| 566 | 165 | * @param string $op the name of variable resolver. should be one of: 'raw', 'enc', or 'encq'. |
|
| 567 | 165 | * |
|
| 568 | 10 | * @return string The rendered string of the token |
|
| 569 | 9 | * |
|
| 570 | * @expect '-&-' when input '-&-', 'raw' |
||
| 571 | 10 | * @expect '-&'-' when input '-&\'-', 'enc' |
|
| 572 | * @expect '-&'-' when input '-&\'-', 'encq' |
||
| 573 | * @expect '-&'-' when input array('-&\'-'), 'enc' |
||
| 574 | * @expect '-&'-' when input array('-&\'-'), 'encq' |
||
| 575 | 165 | * @expect '-&-' when input array('-&-', false), 'enc' |
|
| 576 | 9 | * @expect '-&-' when input array('-&-', false), 'raw' |
|
| 577 | 99 | * @expect '-&-' when input array('-&-', 'raw'), 'enc' |
|
| 578 | 88 | * @expect '-&'-' when input array('-&\'-', 'encq'), 'raw' |
|
| 579 | */ |
||
| 580 | 99 | public static function chret($ret, $op) { |
|
| 596 | 145 | ||
| 597 | 145 | /** |
|
| 598 | * LightnCandy runtime method for Handlebars.js style custom helpers. |
||
| 599 | 145 | * |
|
| 600 | 1 | * @param array<string,array|string|integer> $cx render time context |
|
| 601 | * @param string $ch the name of custom helper to be executed |
||
| 602 | * @param array<array|string|integer>|string|integer|null $vars variables for the helper |
||
| 603 | 145 | * @param string $op the name of variable resolver. should be one of: 'raw', 'enc', or 'encq'. |
|
| 604 | * @param boolean $inverted the logic will be inverted |
||
| 605 | 145 | * @param Closure|null $cb callback function to render child context |
|
| 606 | 145 | * @param Closure|null $else callback function to render child context when {{else}} |
|
| 607 | 145 | * |
|
| 608 | 145 | * @return string The rendered string of the token |
|
| 609 | */ |
||
| 610 | public static function hbch($cx, $ch, $vars, $op, $inverted, $cb = null, $else = null) { |
||
| 708 | |||
| 709 | /** |
||
| 710 | * LightnCandy runtime method for block custom helpers. |
||
| 711 | * |
||
| 712 | 4 | * @param array<string,array|string|integer> $cx render time context |
|
| 713 | 4 | * @param string $ch the name of custom helper to be executed |
|
| 714 | * @param array<array|string|integer>|string|integer|null $vars variables for the helper |
||
| 715 | * @param array<array|string|integer>|string|integer|null $in input data with current scope |
||
| 716 | 4 | * @param boolean $inverted the logic will be inverted |
|
| 717 | 2 | * @param Closure $cb callback function to render child context |
|
| 718 | 2 | * @param Closure|null $else callback function to render child context when {{else}} |
|
| 719 | 2 | * |
|
| 720 | * @return string The rendered string of the token |
||
| 721 | * |
||
| 722 | 4 | * @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);} |
|
| 723 | 4 | * @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);} |
|
| 724 | 2 | * @expect '' when input array('blockhelpers' => array('a' => function ($cx,$in) {})), 'a', array('6', 0), 2, false, function($cx, $i) {return implode('.', $i);} |
|
| 725 | 1 | */ |
|
| 726 | 1 | public static function bch($cx, $ch, $vars, $in, $inverted, $cb, $else = null) { |
|
| 753 | } |
||
| 754 | |||
| 755 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.