Completed
Push — master ( 1be2e7...d38097 )
by Sam
23s
created

SSTemplateParser::Text__finalise()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 1
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 55 and the first side effect is on line 18.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/*
4
WARNING: This file has been machine generated. Do not edit it, or your changes will be overwritten next time it is compiled.
5
*/
6
7
8
9
10
namespace SilverStripe\View;
11
12
use SilverStripe\Core\Injector\Injector;
13
use Parser;
14
use InvalidArgumentException;
15
16
// We want this to work when run by hand too
17
if (defined('THIRDPARTY_PATH')) {
18
    require_once(THIRDPARTY_PATH . '/php-peg/Parser.php');
19
} else {
20
    $base = dirname(__FILE__);
21
    require_once($base.'/../thirdparty/php-peg/Parser.php');
22
}
23
24
/**
25
  * This is the parser for the SilverStripe template language. It gets called on a string and uses a php-peg parser
26
  * to match that string against the language structure, building up the PHP code to execute that structure as it
27
  * parses
28
  *
29
  * The $result array that is built up as part of the parsing (see thirdparty/php-peg/README.md for more on how
30
  * parsers build results) has one special member, 'php', which contains the php equivalent of that part of the
31
  * template tree.
32
  *
33
  * Some match rules generate alternate php, or other variations, so check the per-match documentation too.
34
  *
35
  * Terms used:
36
  *
37
  * Marked: A string or lookup in the template that has been explictly marked as such - lookups by prepending with
38
  * "$" (like $Foo.Bar), strings by wrapping with single or double quotes ('Foo' or "Foo")
39
  *
40
  * Bare: The opposite of marked. An argument that has to has it's type inferred by usage and 2.4 defaults.
41
  *
42
  * Example of using a bare argument for a loop block: <% loop Foo %>
43
  *
44
  * Block: One of two SS template structures. The special characters "<%" and "%>" are used to wrap the opening and
45
  * (required or forbidden depending on which block exactly) closing block marks.
46
  *
47
  * Open Block: An SS template block that doesn't wrap any content or have a closing end tag (in fact, a closing end
48
  * tag is forbidden)
49
  *
50
  * Closed Block: An SS template block that wraps content, and requires a counterpart <% end_blockname %> tag
51
  *
52
  * Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements
53
  * N: eats white space including newlines (using in legacy _t support)
54
  */
55
class SSTemplateParser extends Parser implements TemplateParser
56
{
57
58
    /**
59
     * @var bool - Set true by SSTemplateParser::compileString if the template should include comments intended
60
     * for debugging (template source, included files, etc)
61
     */
62
    protected $includeDebuggingComments = false;
63
64
    /**
65
     * Stores the user-supplied closed block extension rules in the form:
66
     * array(
67
     *   'name' => function (&$res) {}
68
     * )
69
     * See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like
70
     * @var array
71
     */
72
    protected $closedBlocks = array();
73
74
    /**
75
     * Stores the user-supplied open block extension rules in the form:
76
     * array(
77
     *   'name' => function (&$res) {}
78
     * )
79
     * See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like
80
     * @var array
81
     */
82
    protected $openBlocks = array();
83
84
    /**
85
     * Allow the injection of new closed & open block callables
86
     * @param array $closedBlocks
87
     * @param array $openBlocks
88
     */
89
    public function __construct($closedBlocks = array(), $openBlocks = array())
90
    {
91
        parent::__construct(null);
92
        $this->setClosedBlocks($closedBlocks);
93
        $this->setOpenBlocks($openBlocks);
94
    }
95
96
    /**
97
     * Override the function that constructs the result arrays to also prepare a 'php' item in the array
98
     */
99
    function construct($matchrule, $name, $arguments = null)
100
    {
101
        $res = parent::construct($matchrule, $name, $arguments);
102
        if (!isset($res['php'])) {
103
            $res['php'] = '';
104
        }
105
        return $res;
106
    }
107
108
    /**
109
     * Set the closed blocks that the template parser should use
110
     *
111
     * This method will delete any existing closed blocks, please use addClosedBlock if you don't
112
     * want to overwrite
113
     * @param array $closedBlocks
114
     * @throws InvalidArgumentException
115
     */
116
    public function setClosedBlocks($closedBlocks)
117
    {
118
        $this->closedBlocks = array();
119
        foreach ((array) $closedBlocks as $name => $callable) {
120
            $this->addClosedBlock($name, $callable);
121
        }
122
    }
123
124
    /**
125
     * Set the open blocks that the template parser should use
126
     *
127
     * This method will delete any existing open blocks, please use addOpenBlock if you don't
128
     * want to overwrite
129
     * @param array $openBlocks
130
     * @throws InvalidArgumentException
131
     */
132
    public function setOpenBlocks($openBlocks)
133
    {
134
        $this->openBlocks = array();
135
        foreach ((array) $openBlocks as $name => $callable) {
136
            $this->addOpenBlock($name, $callable);
137
        }
138
    }
139
140
    /**
141
     * Add a closed block callable to allow <% name %><% end_name %> syntax
142
     * @param string $name The name of the token to be used in the syntax <% name %><% end_name %>
143
     * @param callable $callable The function that modifies the generation of template code
144
     * @throws InvalidArgumentException
145
     */
146
    public function addClosedBlock($name, $callable)
147
    {
148
        $this->validateExtensionBlock($name, $callable, 'Closed block');
149
        $this->closedBlocks[$name] = $callable;
150
    }
151
152
    /**
153
     * Add a closed block callable to allow <% name %> syntax
154
     * @param string $name The name of the token to be used in the syntax <% name %>
155
     * @param callable $callable The function that modifies the generation of template code
156
     * @throws InvalidArgumentException
157
     */
158
    public function addOpenBlock($name, $callable)
159
    {
160
        $this->validateExtensionBlock($name, $callable, 'Open block');
161
        $this->openBlocks[$name] = $callable;
162
    }
163
164
    /**
165
     * Ensures that the arguments to addOpenBlock and addClosedBlock are valid
166
     * @param $name
167
     * @param $callable
168
     * @param $type
169
     * @throws InvalidArgumentException
170
     */
171
    protected function validateExtensionBlock($name, $callable, $type)
172
    {
173
        if (!is_string($name)) {
174
            throw new InvalidArgumentException(
175
                sprintf(
176
                    "Name argument for %s must be a string",
177
                    $type
178
                )
179
            );
180
        } elseif (!is_callable($callable)) {
181
            throw new InvalidArgumentException(
182
                sprintf(
183
                    "Callable %s argument named '%s' is not callable",
184
                    $type,
185
                    $name
186
                )
187
            );
188
        }
189
    }
190
191
    /* Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
192
	OpenBlock | MalformedBlock | Injection | Text)+ */
193
    protected $match_Template_typestack = array('Template');
194
    function match_Template($stack = array())
195
    {
196
        $matchrule = "Template";
197
        $result = $this->construct($matchrule, $matchrule, null);
198
        $count = 0;
199
        while (true) {
200
            $res_50 = $result;
201
            $pos_50 = $this->pos;
0 ignored issues
show
Bug introduced by
The property pos does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
202
            $_49 = null;
203
            do {
0 ignored issues
show
Unused Code introduced by
do { $_47 = null; ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
204
                $_47 = null;
205
                do {
206
                    $res_0 = $result;
207
                    $pos_0 = $this->pos;
208
                    $matcher = 'match_'.'Comment';
209
                    $key = $matcher;
210
                    $pos = $this->pos;
211
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
212
                    if ($subres !== false) {
213
                        $this->store($result, $subres);
214
                        $_47 = true;
215
                        break;
216
                    }
217
                    $result = $res_0;
218
                    $this->pos = $pos_0;
219
                    $_45 = null;
220
                    do {
221
                        $res_2 = $result;
222
                        $pos_2 = $this->pos;
223
                        $matcher = 'match_'.'Translate';
224
                        $key = $matcher;
225
                        $pos = $this->pos;
226
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
227
                        if ($subres !== false) {
228
                            $this->store($result, $subres);
229
                            $_45 = true;
230
                            break;
231
                        }
232
                        $result = $res_2;
233
                        $this->pos = $pos_2;
234
                        $_43 = null;
235
                        do {
236
                            $res_4 = $result;
237
                            $pos_4 = $this->pos;
238
                            $matcher = 'match_'.'If';
239
                            $key = $matcher;
240
                            $pos = $this->pos;
241
                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
242
                            if ($subres !== false) {
243
                                $this->store($result, $subres);
244
                                $_43 = true;
245
                                break;
246
                            }
247
                            $result = $res_4;
248
                            $this->pos = $pos_4;
249
                            $_41 = null;
250
                            do {
251
                                $res_6 = $result;
252
                                $pos_6 = $this->pos;
253
                                $matcher = 'match_'.'Require';
254
                                $key = $matcher;
255
                                $pos = $this->pos;
256
                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
257
                                if ($subres !== false) {
258
                                    $this->store($result, $subres);
259
                                    $_41 = true;
260
                                    break;
261
                                }
262
                                $result = $res_6;
263
                                $this->pos = $pos_6;
264
                                $_39 = null;
265
                                do {
266
                                    $res_8 = $result;
267
                                    $pos_8 = $this->pos;
268
                                    $matcher = 'match_'.'CacheBlock';
269
                                    $key = $matcher;
270
                                    $pos = $this->pos;
271
                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
272
                                    if ($subres !== false) {
273
                                        $this->store($result, $subres);
274
                                        $_39 = true;
275
                                        break;
276
                                    }
277
                                    $result = $res_8;
278
                                    $this->pos = $pos_8;
279
                                    $_37 = null;
280
                                    do {
281
                                        $res_10 = $result;
282
                                        $pos_10 = $this->pos;
283
                                        $matcher = 'match_'.'UncachedBlock';
284
                                        $key = $matcher;
285
                                        $pos = $this->pos;
286
                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
287
                                        if ($subres !== false) {
288
                                            $this->store($result, $subres);
289
                                            $_37 = true;
290
                                            break;
291
                                        }
292
                                        $result = $res_10;
293
                                        $this->pos = $pos_10;
294
                                        $_35 = null;
295
                                        do {
296
                                            $res_12 = $result;
297
                                            $pos_12 = $this->pos;
298
                                            $matcher = 'match_'.'OldI18NTag';
299
                                            $key = $matcher;
300
                                            $pos = $this->pos;
301
                                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
302
                                            if ($subres !== false) {
303
                                                $this->store($result, $subres);
304
                                                $_35 = true;
305
                                                break;
306
                                            }
307
                                            $result = $res_12;
308
                                            $this->pos = $pos_12;
309
                                            $_33 = null;
310
                                            do {
311
                                                $res_14 = $result;
312
                                                $pos_14 = $this->pos;
313
                                                $matcher = 'match_'.'Include';
314
                                                $key = $matcher;
315
                                                $pos = $this->pos;
316
                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
317
                                                if ($subres !== false) {
318
                                                    $this->store($result, $subres);
319
                                                    $_33 = true;
320
                                                    break;
321
                                                }
322
                                                $result = $res_14;
323
                                                $this->pos = $pos_14;
324
                                                $_31 = null;
325
                                                do {
326
                                                    $res_16 = $result;
327
                                                    $pos_16 = $this->pos;
328
                                                    $matcher = 'match_'.'ClosedBlock';
329
                                                    $key = $matcher;
330
                                                    $pos = $this->pos;
331
                                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
332
                                                    if ($subres !== false) {
333
                                                        $this->store($result, $subres);
334
                                                        $_31 = true;
335
                                                        break;
336
                                                    }
337
                                                    $result = $res_16;
338
                                                    $this->pos = $pos_16;
339
                                                    $_29 = null;
340
                                                    do {
341
                                                        $res_18 = $result;
342
                                                        $pos_18 = $this->pos;
343
                                                        $matcher = 'match_'.'OpenBlock';
344
                                                        $key = $matcher;
345
                                                        $pos = $this->pos;
346
                                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
347
                                                        if ($subres !== false) {
348
                                                            $this->store($result, $subres);
349
                                                            $_29 = true;
350
                                                            break;
351
                                                        }
352
                                                        $result = $res_18;
353
                                                        $this->pos = $pos_18;
354
                                                        $_27 = null;
355
                                                        do {
356
                                                            $res_20 = $result;
357
                                                            $pos_20 = $this->pos;
358
                                                            $matcher = 'match_'.'MalformedBlock';
359
                                                            $key = $matcher;
360
                                                            $pos = $this->pos;
361
                                                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
362
                                                            if ($subres !== false) {
363
                                                                $this->store($result, $subres);
364
                                                                $_27 = true;
365
                                                                break;
366
                                                            }
367
                                                            $result = $res_20;
368
                                                            $this->pos = $pos_20;
369
                                                            $_25 = null;
370
                                                            do {
371
                                                                $res_22 = $result;
372
                                                                $pos_22 = $this->pos;
373
                                                                $matcher = 'match_'.'Injection';
374
                                                                $key = $matcher;
375
                                                                $pos = $this->pos;
376
                                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
377
                                                                if ($subres !== false) {
378
                                                                    $this->store($result, $subres);
379
                                                                    $_25 = true;
380
                                                                    break;
381
                                                                }
382
                                                                $result = $res_22;
383
                                                                $this->pos = $pos_22;
384
                                                                $matcher = 'match_'.'Text';
385
                                                                $key = $matcher;
386
                                                                $pos = $this->pos;
387
                                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
388
                                                                if ($subres !== false) {
389
                                                                    $this->store($result, $subres);
390
                                                                    $_25 = true;
391
                                                                    break;
392
                                                                }
393
                                                                $result = $res_22;
394
                                                                $this->pos = $pos_22;
395
                                                                $_25 = false;
396
                                                                break;
397
                                                            } while (0);
398
                                                            if ($_25 === true) {
399
                                                                $_27 = true;
400
                                                                break;
401
                                                            }
402
                                                            $result = $res_20;
403
                                                            $this->pos = $pos_20;
404
                                                            $_27 = false;
405
                                                            break;
406
                                                        } while (0);
407
                                                        if ($_27 === true) {
408
                                                            $_29 = true;
409
                                                            break;
410
                                                        }
411
                                                        $result = $res_18;
412
                                                        $this->pos = $pos_18;
413
                                                        $_29 = false;
414
                                                        break;
415
                                                    } while (0);
416
                                                    if ($_29 === true) {
417
                                                        $_31 = true;
418
                                                        break;
419
                                                    }
420
                                                    $result = $res_16;
421
                                                    $this->pos = $pos_16;
422
                                                    $_31 = false;
423
                                                    break;
424
                                                } while (0);
425
                                                if ($_31 === true) {
426
                                                    $_33 = true;
427
                                                    break;
428
                                                }
429
                                                $result = $res_14;
430
                                                $this->pos = $pos_14;
431
                                                $_33 = false;
432
                                                break;
433
                                            } while (0);
434
                                            if ($_33 === true) {
435
                                                $_35 = true;
436
                                                break;
437
                                            }
438
                                            $result = $res_12;
439
                                            $this->pos = $pos_12;
440
                                            $_35 = false;
441
                                            break;
442
                                        } while (0);
443
                                        if ($_35 === true) {
444
                                            $_37 = true;
445
                                            break;
446
                                        }
447
                                        $result = $res_10;
448
                                        $this->pos = $pos_10;
449
                                        $_37 = false;
450
                                        break;
451
                                    } while (0);
452
                                    if ($_37 === true) {
453
                                        $_39 = true;
454
                                        break;
455
                                    }
456
                                    $result = $res_8;
457
                                    $this->pos = $pos_8;
458
                                    $_39 = false;
459
                                    break;
460
                                } while (0);
461
                                if ($_39 === true) {
462
                                    $_41 = true;
463
                                    break;
464
                                }
465
                                $result = $res_6;
466
                                $this->pos = $pos_6;
467
                                $_41 = false;
468
                                break;
469
                            } while (0);
470
                            if ($_41 === true) {
471
                                $_43 = true;
472
                                break;
473
                            }
474
                            $result = $res_4;
475
                            $this->pos = $pos_4;
476
                            $_43 = false;
477
                            break;
478
                        } while (0);
479
                        if ($_43 === true) {
480
                            $_45 = true;
481
                            break;
482
                        }
483
                        $result = $res_2;
484
                        $this->pos = $pos_2;
485
                        $_45 = false;
486
                        break;
487
                    } while (0);
488
                    if ($_45 === true) {
489
                        $_47 = true;
490
                        break;
491
                    }
492
                    $result = $res_0;
493
                    $this->pos = $pos_0;
494
                    $_47 = false;
495
                    break;
496
                } while (0);
497
                if ($_47 === false) {
498
                    $_49 = false;
499
                    break;
500
                }
501
                $_49 = true;
502
                break;
503
            } while (0);
504
            if ($_49 === false) {
505
                $result = $res_50;
506
                $this->pos = $pos_50;
507
                unset($res_50);
508
                unset($pos_50);
509
                break;
510
            }
511
            $count += 1;
512
        }
513
        if ($count > 0) {
514
            return $this->finalise($result);
515
        } else {
516
            return false;
517
        }
518
    }
519
520
521
522
    function Template_STR(&$res, $sub)
523
    {
524
        $res['php'] .= $sub['php'] . PHP_EOL ;
525
    }
526
527
    /* Word: / [A-Za-z_] [A-Za-z0-9_]* / */
528
    protected $match_Word_typestack = array('Word');
529
    function match_Word($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
530
    {
531
        $matchrule = "Word";
532
        $result = $this->construct($matchrule, $matchrule, null);
533
        if (( $subres = $this->rx('/ [A-Za-z_] [A-Za-z0-9_]* /') ) !== false) {
534
            $result["text"] .= $subres;
535
            return $this->finalise($result);
536
        } else {
537
            return false;
538
        }
539
    }
540
541
542
    /* NamespacedWord: / [A-Za-z_\/\\] [A-Za-z0-9_\/\\]* / */
543
    protected $match_NamespacedWord_typestack = array('NamespacedWord');
544
    function match_NamespacedWord($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
545
    {
546
        $matchrule = "NamespacedWord";
547
        $result = $this->construct($matchrule, $matchrule, null);
548
        if (( $subres = $this->rx('/ [A-Za-z_\/\\\\] [A-Za-z0-9_\/\\\\]* /') ) !== false) {
549
            $result["text"] .= $subres;
550
            return $this->finalise($result);
551
        } else {
552
            return false;
553
        }
554
    }
555
556
557
    /* Number: / [0-9]+ / */
558
    protected $match_Number_typestack = array('Number');
559
    function match_Number($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
560
    {
561
        $matchrule = "Number";
562
        $result = $this->construct($matchrule, $matchrule, null);
563
        if (( $subres = $this->rx('/ [0-9]+ /') ) !== false) {
564
            $result["text"] .= $subres;
565
            return $this->finalise($result);
566
        } else {
567
            return false;
568
        }
569
    }
570
571
572
    /* Value: / [A-Za-z0-9_]+ / */
573
    protected $match_Value_typestack = array('Value');
574
    function match_Value($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
575
    {
576
        $matchrule = "Value";
577
        $result = $this->construct($matchrule, $matchrule, null);
578
        if (( $subres = $this->rx('/ [A-Za-z0-9_]+ /') ) !== false) {
579
            $result["text"] .= $subres;
580
            return $this->finalise($result);
581
        } else {
582
            return false;
583
        }
584
    }
585
586
587
    /* CallArguments: :Argument ( < "," < :Argument )* */
588
    protected $match_CallArguments_typestack = array('CallArguments');
589
    function match_CallArguments($stack = array())
590
    {
591
        $matchrule = "CallArguments";
592
        $result = $this->construct($matchrule, $matchrule, null);
593
        $_62 = null;
594
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
595
            $matcher = 'match_'.'Argument';
596
            $key = $matcher;
597
            $pos = $this->pos;
598
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
599
            if ($subres !== false) {
600
                $this->store($result, $subres, "Argument");
601
            } else {
602
                $_62 = false;
603
                break;
604
            }
605
            while (true) {
606
                $res_61 = $result;
607
                $pos_61 = $this->pos;
608
                $_60 = null;
609
                do {
610
                    if (( $subres = $this->whitespace() ) !== false) {
611
                        $result["text"] .= $subres;
612
                    }
613
                    if (substr($this->string, $this->pos, 1) == ',') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
614
                        $this->pos += 1;
615
                        $result["text"] .= ',';
616
                    } else {
617
                        $_60 = false;
618
                        break;
619
                    }
620
                    if (( $subres = $this->whitespace() ) !== false) {
621
                        $result["text"] .= $subres;
622
                    }
623
                    $matcher = 'match_'.'Argument';
624
                    $key = $matcher;
625
                    $pos = $this->pos;
626
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
627
                    if ($subres !== false) {
628
                        $this->store($result, $subres, "Argument");
629
                    } else {
630
                        $_60 = false;
631
                        break;
632
                    }
633
                    $_60 = true;
634
                    break;
635
                } while (0);
636
                if ($_60 === false) {
637
                    $result = $res_61;
638
                    $this->pos = $pos_61;
639
                    unset($res_61);
640
                    unset($pos_61);
641
                    break;
642
                }
643
            }
644
            $_62 = true;
645
            break;
646
        } while (0);
647
        if ($_62 === true) {
648
            return $this->finalise($result);
649
        }
650
        if ($_62 === false) {
651
            return false;
652
        }
653
    }
654
655
656
657
658
    /**
659
     * Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert
660
     * strings to numbers when needed.
661
     */
662
    function CallArguments_Argument(&$res, $sub)
663
    {
664
        if (!empty($res['php'])) {
665
            $res['php'] .= ', ';
666
        }
667
668
        $res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] :
669
            str_replace('$$FINAL', 'XML_val', $sub['php']);
670
    }
671
672
    /* Call: Method:Word ( "(" < :CallArguments? > ")" )? */
673
    protected $match_Call_typestack = array('Call');
674
    function match_Call($stack = array())
675
    {
676
        $matchrule = "Call";
677
        $result = $this->construct($matchrule, $matchrule, null);
678
        $_72 = null;
679
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
680
            $matcher = 'match_'.'Word';
681
            $key = $matcher;
682
            $pos = $this->pos;
683
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
684
            if ($subres !== false) {
685
                $this->store($result, $subres, "Method");
686
            } else {
687
                $_72 = false;
688
                break;
689
            }
690
            $res_71 = $result;
691
            $pos_71 = $this->pos;
692
            $_70 = null;
693
            do {
694
                if (substr($this->string, $this->pos, 1) == '(') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
695
                    $this->pos += 1;
696
                    $result["text"] .= '(';
697
                } else {
698
                    $_70 = false;
699
                    break;
700
                }
701
                if (( $subres = $this->whitespace() ) !== false) {
702
                    $result["text"] .= $subres;
703
                }
704
                $res_67 = $result;
705
                $pos_67 = $this->pos;
706
                $matcher = 'match_'.'CallArguments';
707
                $key = $matcher;
708
                $pos = $this->pos;
709
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
710
                if ($subres !== false) {
711
                    $this->store($result, $subres, "CallArguments");
712
                } else {
713
                    $result = $res_67;
714
                    $this->pos = $pos_67;
715
                    unset($res_67);
716
                    unset($pos_67);
717
                }
718
                if (( $subres = $this->whitespace() ) !== false) {
719
                    $result["text"] .= $subres;
720
                }
721
                if (substr($this->string, $this->pos, 1) == ')') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
722
                    $this->pos += 1;
723
                    $result["text"] .= ')';
724
                } else {
725
                    $_70 = false;
726
                    break;
727
                }
728
                $_70 = true;
729
                break;
730
            } while (0);
731
            if ($_70 === false) {
732
                $result = $res_71;
733
                $this->pos = $pos_71;
734
                unset($res_71);
735
                unset($pos_71);
736
            }
737
            $_72 = true;
738
            break;
739
        } while (0);
740
        if ($_72 === true) {
741
            return $this->finalise($result);
742
        }
743
        if ($_72 === false) {
744
            return false;
745
        }
746
    }
747
748
749
    /* LookupStep: :Call &"." */
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
750
    protected $match_LookupStep_typestack = array('LookupStep');
751
    function match_LookupStep($stack = array())
752
    {
753
        $matchrule = "LookupStep";
754
        $result = $this->construct($matchrule, $matchrule, null);
755
        $_76 = null;
756
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
757
            $matcher = 'match_'.'Call';
758
            $key = $matcher;
759
            $pos = $this->pos;
760
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
761
            if ($subres !== false) {
762
                $this->store($result, $subres, "Call");
763
            } else {
764
                $_76 = false;
765
                break;
766
            }
767
            $res_75 = $result;
768
            $pos_75 = $this->pos;
769
            if (substr($this->string, $this->pos, 1) == '.') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
770
                $this->pos += 1;
771
                $result["text"] .= '.';
772
                $result = $res_75;
773
                $this->pos = $pos_75;
774
            } else {
775
                $result = $res_75;
776
                $this->pos = $pos_75;
777
                $_76 = false;
778
                break;
779
            }
780
            $_76 = true;
781
            break;
782
        } while (0);
783
        if ($_76 === true) {
784
            return $this->finalise($result);
785
        }
786
        if ($_76 === false) {
787
            return false;
788
        }
789
    }
790
791
792
    /* LastLookupStep: :Call */
793
    protected $match_LastLookupStep_typestack = array('LastLookupStep');
794
    function match_LastLookupStep($stack = array())
795
    {
796
        $matchrule = "LastLookupStep";
797
        $result = $this->construct($matchrule, $matchrule, null);
798
        $matcher = 'match_'.'Call';
799
        $key = $matcher;
800
        $pos = $this->pos;
801
        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
802
        if ($subres !== false) {
803
            $this->store($result, $subres, "Call");
804
            return $this->finalise($result);
805
        } else {
806
            return false;
807
        }
808
    }
809
810
811
    /* Lookup: LookupStep ("." LookupStep)* "." LastLookupStep | LastLookupStep */
812
    protected $match_Lookup_typestack = array('Lookup');
813
    function match_Lookup($stack = array())
814
    {
815
        $matchrule = "Lookup";
816
        $result = $this->construct($matchrule, $matchrule, null);
817
        $_90 = null;
818
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_79 = $resu... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
819
            $res_79 = $result;
820
            $pos_79 = $this->pos;
821
            $_87 = null;
822
            do {
823
                $matcher = 'match_'.'LookupStep';
824
                $key = $matcher;
825
                $pos = $this->pos;
826
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
827
                if ($subres !== false) {
828
                    $this->store($result, $subres);
829
                } else {
830
                    $_87 = false;
831
                    break;
832
                }
833
                while (true) {
834
                    $res_84 = $result;
835
                    $pos_84 = $this->pos;
836
                    $_83 = null;
837
                    do {
838
                        if (substr($this->string, $this->pos, 1) == '.') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
839
                            $this->pos += 1;
840
                            $result["text"] .= '.';
841
                        } else {
842
                            $_83 = false;
843
                            break;
844
                        }
845
                        $matcher = 'match_'.'LookupStep';
846
                        $key = $matcher;
847
                        $pos = $this->pos;
848
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
849
                        if ($subres !== false) {
850
                            $this->store($result, $subres);
851
                        } else {
852
                            $_83 = false;
853
                            break;
854
                        }
855
                        $_83 = true;
856
                        break;
857
                    } while (0);
858
                    if ($_83 === false) {
859
                        $result = $res_84;
860
                        $this->pos = $pos_84;
861
                        unset($res_84);
862
                        unset($pos_84);
863
                        break;
864
                    }
865
                }
866
                if (substr($this->string, $this->pos, 1) == '.') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
867
                    $this->pos += 1;
868
                    $result["text"] .= '.';
869
                } else {
870
                    $_87 = false;
871
                    break;
872
                }
873
                $matcher = 'match_'.'LastLookupStep';
874
                $key = $matcher;
875
                $pos = $this->pos;
876
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
877
                if ($subres !== false) {
878
                    $this->store($result, $subres);
879
                } else {
880
                    $_87 = false;
881
                    break;
882
                }
883
                $_87 = true;
884
                break;
885
            } while (0);
886
            if ($_87 === true) {
887
                $_90 = true;
888
                break;
889
            }
890
            $result = $res_79;
891
            $this->pos = $pos_79;
892
            $matcher = 'match_'.'LastLookupStep';
893
            $key = $matcher;
894
            $pos = $this->pos;
895
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
896
            if ($subres !== false) {
897
                $this->store($result, $subres);
898
                $_90 = true;
899
                break;
900
            }
901
            $result = $res_79;
902
            $this->pos = $pos_79;
903
            $_90 = false;
904
            break;
905
        } while (0);
906
        if ($_90 === true) {
907
            return $this->finalise($result);
908
        }
909
        if ($_90 === false) {
910
            return false;
911
        }
912
    }
913
914
915
916
917
    function Lookup__construct(&$res)
918
    {
919
        $res['php'] = '$scope->locally()';
920
        $res['LookupSteps'] = array();
921
    }
922
923
    /**
924
     * The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to
925
     * get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
926
     * depending on the context the lookup is used in.
927
     */
928
    function Lookup_AddLookupStep(&$res, $sub, $method)
929
    {
930
        $res['LookupSteps'][] = $sub;
931
932
        $property = $sub['Call']['Method']['text'];
933
934
        if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) {
935
            $res['php'] .= "->$method('$property', array($arguments), true)";
936
        } else {
937
            $res['php'] .= "->$method('$property', null, true)";
938
        }
939
    }
940
941
    function Lookup_LookupStep(&$res, $sub)
942
    {
943
        $this->Lookup_AddLookupStep($res, $sub, 'obj');
944
    }
945
946
    function Lookup_LastLookupStep(&$res, $sub)
947
    {
948
        $this->Lookup_AddLookupStep($res, $sub, '$$FINAL');
949
    }
950
951
952
    /* Translate: "<%t" < Entity < (Default:QuotedString)? < (!("is" "=") < "is" < Context:QuotedString)? <
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
953
	(InjectionVariables)? > "%>" */
954
    protected $match_Translate_typestack = array('Translate');
955
    function match_Translate($stack = array())
956
    {
957
        $matchrule = "Translate";
958
        $result = $this->construct($matchrule, $matchrule, null);
959
        $_116 = null;
960
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
961
            if (( $subres = $this->literal('<%t') ) !== false) {
962
                $result["text"] .= $subres;
963
            } else {
964
                $_116 = false;
965
                break;
966
            }
967
            if (( $subres = $this->whitespace() ) !== false) {
968
                $result["text"] .= $subres;
969
            }
970
            $matcher = 'match_'.'Entity';
971
            $key = $matcher;
972
            $pos = $this->pos;
973
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
974
            if ($subres !== false) {
975
                $this->store($result, $subres);
976
            } else {
977
                $_116 = false;
978
                break;
979
            }
980
            if (( $subres = $this->whitespace() ) !== false) {
981
                $result["text"] .= $subres;
982
            }
983
            $res_98 = $result;
984
            $pos_98 = $this->pos;
985
            $_97 = null;
986
            do {
987
                $matcher = 'match_'.'QuotedString';
988
                $key = $matcher;
989
                $pos = $this->pos;
990
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
991
                if ($subres !== false) {
992
                    $this->store($result, $subres, "Default");
993
                } else {
994
                    $_97 = false;
995
                    break;
996
                }
997
                $_97 = true;
998
                break;
999
            } while (0);
1000
            if ($_97 === false) {
1001
                $result = $res_98;
1002
                $this->pos = $pos_98;
1003
                unset($res_98);
1004
                unset($pos_98);
1005
            }
1006
            if (( $subres = $this->whitespace() ) !== false) {
1007
                $result["text"] .= $subres;
1008
            }
1009
            $res_109 = $result;
1010
            $pos_109 = $this->pos;
1011
            $_108 = null;
1012
            do {
1013
                $res_103 = $result;
1014
                $pos_103 = $this->pos;
1015
                $_102 = null;
1016
                do {
1017
                    if (( $subres = $this->literal('is') ) !== false) {
1018
                        $result["text"] .= $subres;
1019
                    } else {
1020
                        $_102 = false;
1021
                        break;
1022
                    }
1023
                    if (substr($this->string, $this->pos, 1) == '=') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1024
                        $this->pos += 1;
1025
                        $result["text"] .= '=';
1026
                    } else {
1027
                        $_102 = false;
1028
                        break;
1029
                    }
1030
                    $_102 = true;
1031
                    break;
1032
                } while (0);
1033
                if ($_102 === true) {
1034
                    $result = $res_103;
1035
                    $this->pos = $pos_103;
1036
                    $_108 = false;
1037
                    break;
1038
                }
1039
                if ($_102 === false) {
1040
                    $result = $res_103;
1041
                    $this->pos = $pos_103;
1042
                }
1043
                if (( $subres = $this->whitespace() ) !== false) {
1044
                    $result["text"] .= $subres;
1045
                }
1046
                if (( $subres = $this->literal('is') ) !== false) {
1047
                    $result["text"] .= $subres;
1048
                } else {
1049
                    $_108 = false;
1050
                    break;
1051
                }
1052
                if (( $subres = $this->whitespace() ) !== false) {
1053
                    $result["text"] .= $subres;
1054
                }
1055
                $matcher = 'match_'.'QuotedString';
1056
                $key = $matcher;
1057
                $pos = $this->pos;
1058
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1059
                if ($subres !== false) {
1060
                    $this->store($result, $subres, "Context");
1061
                } else {
1062
                    $_108 = false;
1063
                    break;
1064
                }
1065
                $_108 = true;
1066
                break;
1067
            } while (0);
1068
            if ($_108 === false) {
1069
                $result = $res_109;
1070
                $this->pos = $pos_109;
1071
                unset($res_109);
1072
                unset($pos_109);
1073
            }
1074
            if (( $subres = $this->whitespace() ) !== false) {
1075
                $result["text"] .= $subres;
1076
            }
1077
            $res_113 = $result;
1078
            $pos_113 = $this->pos;
1079
            $_112 = null;
1080
            do {
1081
                $matcher = 'match_'.'InjectionVariables';
1082
                $key = $matcher;
1083
                $pos = $this->pos;
1084
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1085
                if ($subres !== false) {
1086
                    $this->store($result, $subres);
1087
                } else {
1088
                    $_112 = false;
1089
                    break;
1090
                }
1091
                $_112 = true;
1092
                break;
1093
            } while (0);
1094
            if ($_112 === false) {
1095
                $result = $res_113;
1096
                $this->pos = $pos_113;
1097
                unset($res_113);
1098
                unset($pos_113);
1099
            }
1100
            if (( $subres = $this->whitespace() ) !== false) {
1101
                $result["text"] .= $subres;
1102
            }
1103
            if (( $subres = $this->literal('%>') ) !== false) {
1104
                $result["text"] .= $subres;
1105
            } else {
1106
                $_116 = false;
1107
                break;
1108
            }
1109
            $_116 = true;
1110
            break;
1111
        } while (0);
1112
        if ($_116 === true) {
1113
            return $this->finalise($result);
1114
        }
1115
        if ($_116 === false) {
1116
            return false;
1117
        }
1118
    }
1119
1120
1121
    /* InjectionVariables: (< InjectionName:Word "=" Argument)+ */
1122
    protected $match_InjectionVariables_typestack = array('InjectionVariables');
1123
    function match_InjectionVariables($stack = array())
1124
    {
1125
        $matchrule = "InjectionVariables";
1126
        $result = $this->construct($matchrule, $matchrule, null);
1127
        $count = 0;
1128
        while (true) {
1129
            $res_123 = $result;
1130
            $pos_123 = $this->pos;
1131
            $_122 = null;
1132
            do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1133
                if (( $subres = $this->whitespace() ) !== false) {
1134
                    $result["text"] .= $subres;
1135
                }
1136
                $matcher = 'match_'.'Word';
1137
                $key = $matcher;
1138
                $pos = $this->pos;
1139
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1140
                if ($subres !== false) {
1141
                    $this->store($result, $subres, "InjectionName");
1142
                } else {
1143
                    $_122 = false;
1144
                    break;
1145
                }
1146
                if (substr($this->string, $this->pos, 1) == '=') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1147
                    $this->pos += 1;
1148
                    $result["text"] .= '=';
1149
                } else {
1150
                    $_122 = false;
1151
                    break;
1152
                }
1153
                $matcher = 'match_'.'Argument';
1154
                $key = $matcher;
1155
                $pos = $this->pos;
1156
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1157
                if ($subres !== false) {
1158
                    $this->store($result, $subres);
1159
                } else {
1160
                    $_122 = false;
1161
                    break;
1162
                }
1163
                $_122 = true;
1164
                break;
1165
            } while (0);
1166
            if ($_122 === false) {
1167
                $result = $res_123;
1168
                $this->pos = $pos_123;
1169
                unset($res_123);
1170
                unset($pos_123);
1171
                break;
1172
            }
1173
            $count += 1;
1174
        }
1175
        if ($count > 0) {
1176
            return $this->finalise($result);
1177
        } else {
1178
            return false;
1179
        }
1180
    }
1181
1182
1183
    /* Entity: / [A-Za-z_] [\w\.]* / */
1184
    protected $match_Entity_typestack = array('Entity');
1185
    function match_Entity($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1186
    {
1187
        $matchrule = "Entity";
1188
        $result = $this->construct($matchrule, $matchrule, null);
1189
        if (( $subres = $this->rx('/ [A-Za-z_] [\w\.]* /') ) !== false) {
1190
            $result["text"] .= $subres;
1191
            return $this->finalise($result);
1192
        } else {
1193
            return false;
1194
        }
1195
    }
1196
1197
1198
1199
1200
    function Translate__construct(&$res)
1201
    {
1202
        $res['php'] = '$val .= _t(';
1203
    }
1204
1205
    function Translate_Entity(&$res, $sub)
1206
    {
1207
        $res['php'] .= "'$sub[text]'";
1208
    }
1209
1210
    function Translate_Default(&$res, $sub)
1211
    {
1212
        $res['php'] .= ",$sub[text]";
1213
    }
1214
1215
    function Translate_Context(&$res, $sub)
1216
    {
1217
        $res['php'] .= ",$sub[text]";
1218
    }
1219
1220
    function Translate_InjectionVariables(&$res, $sub)
1221
    {
1222
        $res['php'] .= ",$sub[php]";
1223
    }
1224
1225
    function Translate__finalise(&$res)
1226
    {
1227
        $res['php'] .= ');';
1228
    }
1229
1230
    function InjectionVariables__construct(&$res)
1231
    {
1232
        $res['php'] = "array(";
1233
    }
1234
1235
    function InjectionVariables_InjectionName(&$res, $sub)
1236
    {
1237
        $res['php'] .= "'$sub[text]'=>";
1238
    }
1239
1240
    function InjectionVariables_Argument(&$res, $sub)
1241
    {
1242
        $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']) . ',';
1243
    }
1244
1245
    function InjectionVariables__finalise(&$res)
1246
    {
1247
        if (substr($res['php'], -1) == ',') {
1248
            $res['php'] = substr($res['php'], 0, -1); //remove last comma in the array
1249
        }
1250
        $res['php'] .= ')';
1251
    }
1252
1253
1254
    /* SimpleInjection: '$' :Lookup */
1255
    protected $match_SimpleInjection_typestack = array('SimpleInjection');
1256
    function match_SimpleInjection($stack = array())
1257
    {
1258
        $matchrule = "SimpleInjection";
1259
        $result = $this->construct($matchrule, $matchrule, null);
1260
        $_127 = null;
1261
        do {
0 ignored issues
show
Unused Code introduced by
do { if (substr($thi... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1262
            if (substr($this->string, $this->pos, 1) == '$') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1263
                $this->pos += 1;
1264
                $result["text"] .= '$';
1265
            } else {
1266
                $_127 = false;
1267
                break;
1268
            }
1269
            $matcher = 'match_'.'Lookup';
1270
            $key = $matcher;
1271
            $pos = $this->pos;
1272
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1273
            if ($subres !== false) {
1274
                $this->store($result, $subres, "Lookup");
1275
            } else {
1276
                $_127 = false;
1277
                break;
1278
            }
1279
            $_127 = true;
1280
            break;
1281
        } while (0);
1282
        if ($_127 === true) {
1283
            return $this->finalise($result);
1284
        }
1285
        if ($_127 === false) {
1286
            return false;
1287
        }
1288
    }
1289
1290
1291
    /* BracketInjection: '{$' :Lookup "}" */
1292
    protected $match_BracketInjection_typestack = array('BracketInjection');
1293
    function match_BracketInjection($stack = array())
1294
    {
1295
        $matchrule = "BracketInjection";
1296
        $result = $this->construct($matchrule, $matchrule, null);
1297
        $_132 = null;
1298
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1299
            if (( $subres = $this->literal('{$') ) !== false) {
1300
                $result["text"] .= $subres;
1301
            } else {
1302
                $_132 = false;
1303
                break;
1304
            }
1305
            $matcher = 'match_'.'Lookup';
1306
            $key = $matcher;
1307
            $pos = $this->pos;
1308
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1309
            if ($subres !== false) {
1310
                $this->store($result, $subres, "Lookup");
1311
            } else {
1312
                $_132 = false;
1313
                break;
1314
            }
1315
            if (substr($this->string, $this->pos, 1) == '}') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1316
                $this->pos += 1;
1317
                $result["text"] .= '}';
1318
            } else {
1319
                $_132 = false;
1320
                break;
1321
            }
1322
            $_132 = true;
1323
            break;
1324
        } while (0);
1325
        if ($_132 === true) {
1326
            return $this->finalise($result);
1327
        }
1328
        if ($_132 === false) {
1329
            return false;
1330
        }
1331
    }
1332
1333
1334
    /* Injection: BracketInjection | SimpleInjection */
1335
    protected $match_Injection_typestack = array('Injection');
1336
    function match_Injection($stack = array())
1337
    {
1338
        $matchrule = "Injection";
1339
        $result = $this->construct($matchrule, $matchrule, null);
1340
        $_137 = null;
1341
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_134 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1342
            $res_134 = $result;
1343
            $pos_134 = $this->pos;
1344
            $matcher = 'match_'.'BracketInjection';
1345
            $key = $matcher;
1346
            $pos = $this->pos;
1347
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1348
            if ($subres !== false) {
1349
                $this->store($result, $subres);
1350
                $_137 = true;
1351
                break;
1352
            }
1353
            $result = $res_134;
1354
            $this->pos = $pos_134;
1355
            $matcher = 'match_'.'SimpleInjection';
1356
            $key = $matcher;
1357
            $pos = $this->pos;
1358
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1359
            if ($subres !== false) {
1360
                $this->store($result, $subres);
1361
                $_137 = true;
1362
                break;
1363
            }
1364
            $result = $res_134;
1365
            $this->pos = $pos_134;
1366
            $_137 = false;
1367
            break;
1368
        } while (0);
1369
        if ($_137 === true) {
1370
            return $this->finalise($result);
1371
        }
1372
        if ($_137 === false) {
1373
            return false;
1374
        }
1375
    }
1376
1377
1378
1379
    function Injection_STR(&$res, $sub)
1380
    {
1381
        $res['php'] = '$val .= '. str_replace('$$FINAL', 'XML_val', $sub['Lookup']['php']) . ';';
1382
    }
1383
1384
    /* DollarMarkedLookup: SimpleInjection */
1385
    protected $match_DollarMarkedLookup_typestack = array('DollarMarkedLookup');
1386
    function match_DollarMarkedLookup($stack = array())
1387
    {
1388
        $matchrule = "DollarMarkedLookup";
1389
        $result = $this->construct($matchrule, $matchrule, null);
1390
        $matcher = 'match_'.'SimpleInjection';
1391
        $key = $matcher;
1392
        $pos = $this->pos;
1393
        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1394
        if ($subres !== false) {
1395
            $this->store($result, $subres);
1396
            return $this->finalise($result);
1397
        } else {
1398
            return false;
1399
        }
1400
    }
1401
1402
1403
1404
    function DollarMarkedLookup_STR(&$res, $sub)
1405
    {
1406
        $res['Lookup'] = $sub['Lookup'];
1407
    }
1408
1409
    /* QuotedString: q:/['"]/   String:/ (\\\\ | \\. | [^$q\\])* /   '$q' */
1410
    protected $match_QuotedString_typestack = array('QuotedString');
1411
    function match_QuotedString($stack = array())
1412
    {
1413
        $matchrule = "QuotedString";
1414
        $result = $this->construct($matchrule, $matchrule, null);
1415
        $_143 = null;
1416
        do {
0 ignored issues
show
Unused Code introduced by
do { $stack[] = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1417
            $stack[] = $result;
1418
            $result = $this->construct($matchrule, "q");
1419
            if (( $subres = $this->rx('/[\'"]/') ) !== false) {
1420
                $result["text"] .= $subres;
1421
                $subres = $result;
1422
                $result = array_pop($stack);
1423
                $this->store($result, $subres, 'q');
1424
            } else {
1425
                $result = array_pop($stack);
1426
                $_143 = false;
1427
                break;
1428
            }
1429
            $stack[] = $result;
1430
            $result = $this->construct($matchrule, "String");
1431
            if (( $subres = $this->rx('/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /') ) !== false) {
1432
                $result["text"] .= $subres;
1433
                $subres = $result;
1434
                $result = array_pop($stack);
1435
                $this->store($result, $subres, 'String');
1436
            } else {
1437
                $result = array_pop($stack);
1438
                $_143 = false;
1439
                break;
1440
            }
1441
            if (( $subres = $this->literal(''.$this->expression($result, $stack, 'q').'') ) !== false) {
1442
                $result["text"] .= $subres;
1443
            } else {
1444
                $_143 = false;
1445
                break;
1446
            }
1447
            $_143 = true;
1448
            break;
1449
        } while (0);
1450
        if ($_143 === true) {
1451
            return $this->finalise($result);
1452
        }
1453
        if ($_143 === false) {
1454
            return false;
1455
        }
1456
    }
1457
1458
1459
    /* FreeString: /[^,)%!=><|&]+/ */
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1460
    protected $match_FreeString_typestack = array('FreeString');
1461
    function match_FreeString($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1462
    {
1463
        $matchrule = "FreeString";
1464
        $result = $this->construct($matchrule, $matchrule, null);
1465
        if (( $subres = $this->rx('/[^,)%!=><|&]+/') ) !== false) {
1466
            $result["text"] .= $subres;
1467
            return $this->finalise($result);
1468
        } else {
1469
            return false;
1470
        }
1471
    }
1472
1473
1474
    /* Argument:
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1475
	:DollarMarkedLookup |
1476
	:QuotedString |
1477
	:Lookup !(< FreeString)|
1478
	:FreeString */
1479
    protected $match_Argument_typestack = array('Argument');
1480
    function match_Argument($stack = array())
1481
    {
1482
        $matchrule = "Argument";
1483
        $result = $this->construct($matchrule, $matchrule, null);
1484
        $_163 = null;
1485
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_146 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1486
            $res_146 = $result;
1487
            $pos_146 = $this->pos;
1488
            $matcher = 'match_'.'DollarMarkedLookup';
1489
            $key = $matcher;
1490
            $pos = $this->pos;
1491
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1492
            if ($subres !== false) {
1493
                $this->store($result, $subres, "DollarMarkedLookup");
1494
                $_163 = true;
1495
                break;
1496
            }
1497
            $result = $res_146;
1498
            $this->pos = $pos_146;
1499
            $_161 = null;
1500
            do {
1501
                $res_148 = $result;
1502
                $pos_148 = $this->pos;
1503
                $matcher = 'match_'.'QuotedString';
1504
                $key = $matcher;
1505
                $pos = $this->pos;
1506
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1507
                if ($subres !== false) {
1508
                    $this->store($result, $subres, "QuotedString");
1509
                    $_161 = true;
1510
                    break;
1511
                }
1512
                $result = $res_148;
1513
                $this->pos = $pos_148;
1514
                $_159 = null;
1515
                do {
1516
                    $res_150 = $result;
1517
                    $pos_150 = $this->pos;
1518
                    $_156 = null;
1519
                    do {
1520
                        $matcher = 'match_'.'Lookup';
1521
                        $key = $matcher;
1522
                        $pos = $this->pos;
1523
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1524
                        if ($subres !== false) {
1525
                            $this->store($result, $subres, "Lookup");
1526
                        } else {
1527
                            $_156 = false;
1528
                            break;
1529
                        }
1530
                        $res_155 = $result;
1531
                        $pos_155 = $this->pos;
1532
                        $_154 = null;
1533
                        do {
1534
                            if (( $subres = $this->whitespace() ) !== false) {
1535
                                $result["text"] .= $subres;
1536
                            }
1537
                            $matcher = 'match_'.'FreeString';
1538
                            $key = $matcher;
1539
                            $pos = $this->pos;
1540
                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1541
                            if ($subres !== false) {
1542
                                $this->store($result, $subres);
1543
                            } else {
1544
                                $_154 = false;
1545
                                break;
1546
                            }
1547
                            $_154 = true;
1548
                            break;
1549
                        } while (0);
1550
                        if ($_154 === true) {
1551
                            $result = $res_155;
1552
                            $this->pos = $pos_155;
1553
                            $_156 = false;
1554
                            break;
1555
                        }
1556
                        if ($_154 === false) {
1557
                            $result = $res_155;
1558
                            $this->pos = $pos_155;
1559
                        }
1560
                        $_156 = true;
1561
                        break;
1562
                    } while (0);
1563
                    if ($_156 === true) {
1564
                        $_159 = true;
1565
                        break;
1566
                    }
1567
                    $result = $res_150;
1568
                    $this->pos = $pos_150;
1569
                    $matcher = 'match_'.'FreeString';
1570
                    $key = $matcher;
1571
                    $pos = $this->pos;
1572
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1573
                    if ($subres !== false) {
1574
                        $this->store($result, $subres, "FreeString");
1575
                        $_159 = true;
1576
                        break;
1577
                    }
1578
                    $result = $res_150;
1579
                    $this->pos = $pos_150;
1580
                    $_159 = false;
1581
                    break;
1582
                } while (0);
1583
                if ($_159 === true) {
1584
                    $_161 = true;
1585
                    break;
1586
                }
1587
                $result = $res_148;
1588
                $this->pos = $pos_148;
1589
                $_161 = false;
1590
                break;
1591
            } while (0);
1592
            if ($_161 === true) {
1593
                $_163 = true;
1594
                break;
1595
            }
1596
            $result = $res_146;
1597
            $this->pos = $pos_146;
1598
            $_163 = false;
1599
            break;
1600
        } while (0);
1601
        if ($_163 === true) {
1602
            return $this->finalise($result);
1603
        }
1604
        if ($_163 === false) {
1605
            return false;
1606
        }
1607
    }
1608
1609
1610
1611
1612
    /**
1613
     * If we get a bare value, we don't know enough to determine exactly what php would be the translation, because
1614
     * we don't know if the position of use indicates a lookup or a string argument.
1615
     *
1616
     * Instead, we record 'ArgumentMode' as a member of this matches results node, which can be:
1617
     *   - lookup if this argument was unambiguously a lookup (marked as such)
1618
     *   - string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup)
1619
     *   - default if this argument needs to be handled as per 2.4
1620
     *
1621
     * In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which
1622
     * should be used by the parent if the context indicates a lookup, and 'string_php' which should be used
1623
     * if the context indicates a string
1624
     */
1625
1626
    function Argument_DollarMarkedLookup(&$res, $sub)
1627
    {
1628
        $res['ArgumentMode'] = 'lookup';
1629
        $res['php'] = $sub['Lookup']['php'];
1630
    }
1631
1632
    function Argument_QuotedString(&$res, $sub)
1633
    {
1634
        $res['ArgumentMode'] = 'string';
1635
        $res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'";
1636
    }
1637
1638
    function Argument_Lookup(&$res, $sub)
1639
    {
1640
        if (count($sub['LookupSteps']) == 1 && !isset($sub['LookupSteps'][0]['Call']['Arguments'])) {
1641
            $res['ArgumentMode'] = 'default';
1642
            $res['lookup_php'] = $sub['php'];
1643
            $res['string_php'] = "'".$sub['LookupSteps'][0]['Call']['Method']['text']."'";
1644
        } else {
1645
            $res['ArgumentMode'] = 'lookup';
1646
            $res['php'] = $sub['php'];
1647
        }
1648
    }
1649
1650
    function Argument_FreeString(&$res, $sub)
1651
    {
1652
        $res['ArgumentMode'] = 'string';
1653
        $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'";
1654
    }
1655
1656
    /* ComparisonOperator: "!=" | "==" | ">=" | ">" | "<=" | "<" | "=" */
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1657
    protected $match_ComparisonOperator_typestack = array('ComparisonOperator');
1658
    function match_ComparisonOperator($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1659
    {
1660
        $matchrule = "ComparisonOperator";
1661
        $result = $this->construct($matchrule, $matchrule, null);
1662
        $_188 = null;
1663
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_165 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1664
            $res_165 = $result;
1665
            $pos_165 = $this->pos;
1666
            if (( $subres = $this->literal('!=') ) !== false) {
1667
                $result["text"] .= $subres;
1668
                $_188 = true;
1669
                break;
1670
            }
1671
            $result = $res_165;
1672
            $this->pos = $pos_165;
1673
            $_186 = null;
1674
            do {
1675
                $res_167 = $result;
1676
                $pos_167 = $this->pos;
1677
                if (( $subres = $this->literal('==') ) !== false) {
1678
                    $result["text"] .= $subres;
1679
                    $_186 = true;
1680
                    break;
1681
                }
1682
                $result = $res_167;
1683
                $this->pos = $pos_167;
1684
                $_184 = null;
1685
                do {
1686
                    $res_169 = $result;
1687
                    $pos_169 = $this->pos;
1688
                    if (( $subres = $this->literal('>=') ) !== false) {
1689
                        $result["text"] .= $subres;
1690
                        $_184 = true;
1691
                        break;
1692
                    }
1693
                    $result = $res_169;
1694
                    $this->pos = $pos_169;
1695
                    $_182 = null;
1696
                    do {
1697
                        $res_171 = $result;
1698
                        $pos_171 = $this->pos;
1699
                        if (substr($this->string, $this->pos, 1) == '>') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1700
                            $this->pos += 1;
1701
                            $result["text"] .= '>';
1702
                            $_182 = true;
1703
                            break;
1704
                        }
1705
                        $result = $res_171;
1706
                        $this->pos = $pos_171;
1707
                        $_180 = null;
1708
                        do {
1709
                            $res_173 = $result;
1710
                            $pos_173 = $this->pos;
1711
                            if (( $subres = $this->literal('<=') ) !== false) {
1712
                                $result["text"] .= $subres;
1713
                                $_180 = true;
1714
                                break;
1715
                            }
1716
                            $result = $res_173;
1717
                            $this->pos = $pos_173;
1718
                            $_178 = null;
1719
                            do {
1720
                                $res_175 = $result;
1721
                                $pos_175 = $this->pos;
1722
                                if (substr($this->string, $this->pos, 1) == '<') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1723
                                    $this->pos += 1;
1724
                                    $result["text"] .= '<';
1725
                                    $_178 = true;
1726
                                    break;
1727
                                }
1728
                                $result = $res_175;
1729
                                $this->pos = $pos_175;
1730
                                if (substr($this->string, $this->pos, 1) == '=') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1731
                                    $this->pos += 1;
1732
                                    $result["text"] .= '=';
1733
                                    $_178 = true;
1734
                                    break;
1735
                                }
1736
                                $result = $res_175;
1737
                                $this->pos = $pos_175;
1738
                                $_178 = false;
1739
                                break;
1740
                            } while (0);
1741
                            if ($_178 === true) {
1742
                                $_180 = true;
1743
                                break;
1744
                            }
1745
                            $result = $res_173;
1746
                            $this->pos = $pos_173;
1747
                            $_180 = false;
1748
                            break;
1749
                        } while (0);
1750
                        if ($_180 === true) {
1751
                            $_182 = true;
1752
                            break;
1753
                        }
1754
                        $result = $res_171;
1755
                        $this->pos = $pos_171;
1756
                        $_182 = false;
1757
                        break;
1758
                    } while (0);
1759
                    if ($_182 === true) {
1760
                        $_184 = true;
1761
                        break;
1762
                    }
1763
                    $result = $res_169;
1764
                    $this->pos = $pos_169;
1765
                    $_184 = false;
1766
                    break;
1767
                } while (0);
1768
                if ($_184 === true) {
1769
                    $_186 = true;
1770
                    break;
1771
                }
1772
                $result = $res_167;
1773
                $this->pos = $pos_167;
1774
                $_186 = false;
1775
                break;
1776
            } while (0);
1777
            if ($_186 === true) {
1778
                $_188 = true;
1779
                break;
1780
            }
1781
            $result = $res_165;
1782
            $this->pos = $pos_165;
1783
            $_188 = false;
1784
            break;
1785
        } while (0);
1786
        if ($_188 === true) {
1787
            return $this->finalise($result);
1788
        }
1789
        if ($_188 === false) {
1790
            return false;
1791
        }
1792
    }
1793
1794
1795
    /* Comparison: Argument < ComparisonOperator > Argument */
1796
    protected $match_Comparison_typestack = array('Comparison');
1797
    function match_Comparison($stack = array())
1798
    {
1799
        $matchrule = "Comparison";
1800
        $result = $this->construct($matchrule, $matchrule, null);
1801
        $_195 = null;
1802
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1803
            $matcher = 'match_'.'Argument';
1804
            $key = $matcher;
1805
            $pos = $this->pos;
1806
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1807
            if ($subres !== false) {
1808
                $this->store($result, $subres);
1809
            } else {
1810
                $_195 = false;
1811
                break;
1812
            }
1813
            if (( $subres = $this->whitespace() ) !== false) {
1814
                $result["text"] .= $subres;
1815
            }
1816
            $matcher = 'match_'.'ComparisonOperator';
1817
            $key = $matcher;
1818
            $pos = $this->pos;
1819
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1820
            if ($subres !== false) {
1821
                $this->store($result, $subres);
1822
            } else {
1823
                $_195 = false;
1824
                break;
1825
            }
1826
            if (( $subres = $this->whitespace() ) !== false) {
1827
                $result["text"] .= $subres;
1828
            }
1829
            $matcher = 'match_'.'Argument';
1830
            $key = $matcher;
1831
            $pos = $this->pos;
1832
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1833
            if ($subres !== false) {
1834
                $this->store($result, $subres);
1835
            } else {
1836
                $_195 = false;
1837
                break;
1838
            }
1839
            $_195 = true;
1840
            break;
1841
        } while (0);
1842
        if ($_195 === true) {
1843
            return $this->finalise($result);
1844
        }
1845
        if ($_195 === false) {
1846
            return false;
1847
        }
1848
    }
1849
1850
1851
1852
    function Comparison_Argument(&$res, $sub)
1853
    {
1854
        if ($sub['ArgumentMode'] == 'default') {
1855
            if (!empty($res['php'])) {
1856
                $res['php'] .= $sub['string_php'];
1857
            } else {
1858
                $res['php'] = str_replace('$$FINAL', 'XML_val', $sub['lookup_php']);
1859
            }
1860
        } else {
1861
            $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
1862
        }
1863
    }
1864
1865
    function Comparison_ComparisonOperator(&$res, $sub)
1866
    {
1867
        $res['php'] .= ($sub['text'] == '=' ? '==' : $sub['text']);
1868
    }
1869
1870
    /* PresenceCheck: (Not:'not' <)? Argument */
1871
    protected $match_PresenceCheck_typestack = array('PresenceCheck');
1872
    function match_PresenceCheck($stack = array())
1873
    {
1874
        $matchrule = "PresenceCheck";
1875
        $result = $this->construct($matchrule, $matchrule, null);
1876
        $_202 = null;
1877
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_200 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1878
            $res_200 = $result;
1879
            $pos_200 = $this->pos;
1880
            $_199 = null;
1881
            do {
1882
                $stack[] = $result;
1883
                $result = $this->construct($matchrule, "Not");
1884
                if (( $subres = $this->literal('not') ) !== false) {
1885
                    $result["text"] .= $subres;
1886
                    $subres = $result;
1887
                    $result = array_pop($stack);
1888
                    $this->store($result, $subres, 'Not');
1889
                } else {
1890
                    $result = array_pop($stack);
1891
                    $_199 = false;
1892
                    break;
1893
                }
1894
                if (( $subres = $this->whitespace() ) !== false) {
1895
                    $result["text"] .= $subres;
1896
                }
1897
                $_199 = true;
1898
                break;
1899
            } while (0);
1900
            if ($_199 === false) {
1901
                $result = $res_200;
1902
                $this->pos = $pos_200;
1903
                unset($res_200);
1904
                unset($pos_200);
1905
            }
1906
            $matcher = 'match_'.'Argument';
1907
            $key = $matcher;
1908
            $pos = $this->pos;
1909
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1910
            if ($subres !== false) {
1911
                $this->store($result, $subres);
1912
            } else {
1913
                $_202 = false;
1914
                break;
1915
            }
1916
            $_202 = true;
1917
            break;
1918
        } while (0);
1919
        if ($_202 === true) {
1920
            return $this->finalise($result);
1921
        }
1922
        if ($_202 === false) {
1923
            return false;
1924
        }
1925
    }
1926
1927
1928
1929
    function PresenceCheck_Not(&$res, $sub)
0 ignored issues
show
Unused Code introduced by
The parameter $sub is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1930
    {
1931
        $res['php'] = '!';
1932
    }
1933
1934
    function PresenceCheck_Argument(&$res, $sub)
1935
    {
1936
        if ($sub['ArgumentMode'] == 'string') {
1937
            $res['php'] .= '((bool)'.$sub['php'].')';
1938
        } else {
1939
            $php = ($sub['ArgumentMode'] == 'default' ? $sub['lookup_php'] : $sub['php']);
1940
            // TODO: kinda hacky - maybe we need a way to pass state down the parse chain so
1941
            // Lookup_LastLookupStep and Argument_BareWord can produce hasValue instead of XML_val
1942
            $res['php'] .= str_replace('$$FINAL', 'hasValue', $php);
1943
        }
1944
    }
1945
1946
    /* IfArgumentPortion: Comparison | PresenceCheck */
1947
    protected $match_IfArgumentPortion_typestack = array('IfArgumentPortion');
1948
    function match_IfArgumentPortion($stack = array())
1949
    {
1950
        $matchrule = "IfArgumentPortion";
1951
        $result = $this->construct($matchrule, $matchrule, null);
1952
        $_207 = null;
1953
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_204 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
1954
            $res_204 = $result;
1955
            $pos_204 = $this->pos;
1956
            $matcher = 'match_'.'Comparison';
1957
            $key = $matcher;
1958
            $pos = $this->pos;
1959
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1960
            if ($subres !== false) {
1961
                $this->store($result, $subres);
1962
                $_207 = true;
1963
                break;
1964
            }
1965
            $result = $res_204;
1966
            $this->pos = $pos_204;
1967
            $matcher = 'match_'.'PresenceCheck';
1968
            $key = $matcher;
1969
            $pos = $this->pos;
1970
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
1971
            if ($subres !== false) {
1972
                $this->store($result, $subres);
1973
                $_207 = true;
1974
                break;
1975
            }
1976
            $result = $res_204;
1977
            $this->pos = $pos_204;
1978
            $_207 = false;
1979
            break;
1980
        } while (0);
1981
        if ($_207 === true) {
1982
            return $this->finalise($result);
1983
        }
1984
        if ($_207 === false) {
1985
            return false;
1986
        }
1987
    }
1988
1989
1990
1991
    function IfArgumentPortion_STR(&$res, $sub)
1992
    {
1993
        $res['php'] = $sub['php'];
1994
    }
1995
1996
    /* BooleanOperator: "||" | "&&" */
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
1997
    protected $match_BooleanOperator_typestack = array('BooleanOperator');
1998
    function match_BooleanOperator($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1999
    {
2000
        $matchrule = "BooleanOperator";
2001
        $result = $this->construct($matchrule, $matchrule, null);
2002
        $_212 = null;
2003
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_209 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2004
            $res_209 = $result;
2005
            $pos_209 = $this->pos;
2006
            if (( $subres = $this->literal('||') ) !== false) {
2007
                $result["text"] .= $subres;
2008
                $_212 = true;
2009
                break;
2010
            }
2011
            $result = $res_209;
2012
            $this->pos = $pos_209;
2013
            if (( $subres = $this->literal('&&') ) !== false) {
2014
                $result["text"] .= $subres;
2015
                $_212 = true;
2016
                break;
2017
            }
2018
            $result = $res_209;
2019
            $this->pos = $pos_209;
2020
            $_212 = false;
2021
            break;
2022
        } while (0);
2023
        if ($_212 === true) {
2024
            return $this->finalise($result);
2025
        }
2026
        if ($_212 === false) {
2027
            return false;
2028
        }
2029
    }
2030
2031
2032
    /* IfArgument: :IfArgumentPortion ( < :BooleanOperator < :IfArgumentPortion )* */
2033
    protected $match_IfArgument_typestack = array('IfArgument');
2034
    function match_IfArgument($stack = array())
2035
    {
2036
        $matchrule = "IfArgument";
2037
        $result = $this->construct($matchrule, $matchrule, null);
2038
        $_221 = null;
2039
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2040
            $matcher = 'match_'.'IfArgumentPortion';
2041
            $key = $matcher;
2042
            $pos = $this->pos;
2043
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2044
            if ($subres !== false) {
2045
                $this->store($result, $subres, "IfArgumentPortion");
2046
            } else {
2047
                $_221 = false;
2048
                break;
2049
            }
2050
            while (true) {
2051
                $res_220 = $result;
2052
                $pos_220 = $this->pos;
2053
                $_219 = null;
2054
                do {
2055
                    if (( $subres = $this->whitespace() ) !== false) {
2056
                        $result["text"] .= $subres;
2057
                    }
2058
                    $matcher = 'match_'.'BooleanOperator';
2059
                    $key = $matcher;
2060
                    $pos = $this->pos;
2061
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2062
                    if ($subres !== false) {
2063
                        $this->store($result, $subres, "BooleanOperator");
2064
                    } else {
2065
                        $_219 = false;
2066
                        break;
2067
                    }
2068
                    if (( $subres = $this->whitespace() ) !== false) {
2069
                        $result["text"] .= $subres;
2070
                    }
2071
                    $matcher = 'match_'.'IfArgumentPortion';
2072
                    $key = $matcher;
2073
                    $pos = $this->pos;
2074
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2075
                    if ($subres !== false) {
2076
                        $this->store($result, $subres, "IfArgumentPortion");
2077
                    } else {
2078
                        $_219 = false;
2079
                        break;
2080
                    }
2081
                    $_219 = true;
2082
                    break;
2083
                } while (0);
2084
                if ($_219 === false) {
2085
                    $result = $res_220;
2086
                    $this->pos = $pos_220;
2087
                    unset($res_220);
2088
                    unset($pos_220);
2089
                    break;
2090
                }
2091
            }
2092
            $_221 = true;
2093
            break;
2094
        } while (0);
2095
        if ($_221 === true) {
2096
            return $this->finalise($result);
2097
        }
2098
        if ($_221 === false) {
2099
            return false;
2100
        }
2101
    }
2102
2103
2104
2105
    function IfArgument_IfArgumentPortion(&$res, $sub)
2106
    {
2107
        $res['php'] .= $sub['php'];
2108
    }
2109
2110
    function IfArgument_BooleanOperator(&$res, $sub)
2111
    {
2112
        $res['php'] .= $sub['text'];
2113
    }
2114
2115
    /* IfPart: '<%' < 'if' [ :IfArgument > '%>' Template:$TemplateMatcher? */
2116
    protected $match_IfPart_typestack = array('IfPart');
2117
    function match_IfPart($stack = array())
2118
    {
2119
        $matchrule = "IfPart";
2120
        $result = $this->construct($matchrule, $matchrule, null);
2121
        $_231 = null;
2122
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2123
            if (( $subres = $this->literal('<%') ) !== false) {
2124
                $result["text"] .= $subres;
2125
            } else {
2126
                $_231 = false;
2127
                break;
2128
            }
2129
            if (( $subres = $this->whitespace() ) !== false) {
2130
                $result["text"] .= $subres;
2131
            }
2132
            if (( $subres = $this->literal('if') ) !== false) {
2133
                $result["text"] .= $subres;
2134
            } else {
2135
                $_231 = false;
2136
                break;
2137
            }
2138
            if (( $subres = $this->whitespace() ) !== false) {
2139
                $result["text"] .= $subres;
2140
            } else {
2141
                $_231 = false;
2142
                break;
2143
            }
2144
            $matcher = 'match_'.'IfArgument';
2145
            $key = $matcher;
2146
            $pos = $this->pos;
2147
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2148
            if ($subres !== false) {
2149
                $this->store($result, $subres, "IfArgument");
2150
            } else {
2151
                $_231 = false;
2152
                break;
2153
            }
2154
            if (( $subres = $this->whitespace() ) !== false) {
2155
                $result["text"] .= $subres;
2156
            }
2157
            if (( $subres = $this->literal('%>') ) !== false) {
2158
                $result["text"] .= $subres;
2159
            } else {
2160
                $_231 = false;
2161
                break;
2162
            }
2163
            $res_230 = $result;
2164
            $pos_230 = $this->pos;
2165
            $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher');
2166
            $key = $matcher;
2167
            $pos = $this->pos;
2168
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2169
            if ($subres !== false) {
2170
                $this->store($result, $subres, "Template");
2171
            } else {
2172
                $result = $res_230;
2173
                $this->pos = $pos_230;
2174
                unset($res_230);
2175
                unset($pos_230);
2176
            }
2177
            $_231 = true;
2178
            break;
2179
        } while (0);
2180
        if ($_231 === true) {
2181
            return $this->finalise($result);
2182
        }
2183
        if ($_231 === false) {
2184
            return false;
2185
        }
2186
    }
2187
2188
2189
    /* ElseIfPart: '<%' < 'else_if' [ :IfArgument > '%>' Template:$TemplateMatcher? */
2190
    protected $match_ElseIfPart_typestack = array('ElseIfPart');
2191
    function match_ElseIfPart($stack = array())
2192
    {
2193
        $matchrule = "ElseIfPart";
2194
        $result = $this->construct($matchrule, $matchrule, null);
2195
        $_241 = null;
2196
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2197
            if (( $subres = $this->literal('<%') ) !== false) {
2198
                $result["text"] .= $subres;
2199
            } else {
2200
                $_241 = false;
2201
                break;
2202
            }
2203
            if (( $subres = $this->whitespace() ) !== false) {
2204
                $result["text"] .= $subres;
2205
            }
2206
            if (( $subres = $this->literal('else_if') ) !== false) {
2207
                $result["text"] .= $subres;
2208
            } else {
2209
                $_241 = false;
2210
                break;
2211
            }
2212
            if (( $subres = $this->whitespace() ) !== false) {
2213
                $result["text"] .= $subres;
2214
            } else {
2215
                $_241 = false;
2216
                break;
2217
            }
2218
            $matcher = 'match_'.'IfArgument';
2219
            $key = $matcher;
2220
            $pos = $this->pos;
2221
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2222
            if ($subres !== false) {
2223
                $this->store($result, $subres, "IfArgument");
2224
            } else {
2225
                $_241 = false;
2226
                break;
2227
            }
2228
            if (( $subres = $this->whitespace() ) !== false) {
2229
                $result["text"] .= $subres;
2230
            }
2231
            if (( $subres = $this->literal('%>') ) !== false) {
2232
                $result["text"] .= $subres;
2233
            } else {
2234
                $_241 = false;
2235
                break;
2236
            }
2237
            $res_240 = $result;
2238
            $pos_240 = $this->pos;
2239
            $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher');
2240
            $key = $matcher;
2241
            $pos = $this->pos;
2242
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2243
            if ($subres !== false) {
2244
                $this->store($result, $subres, "Template");
2245
            } else {
2246
                $result = $res_240;
2247
                $this->pos = $pos_240;
2248
                unset($res_240);
2249
                unset($pos_240);
2250
            }
2251
            $_241 = true;
2252
            break;
2253
        } while (0);
2254
        if ($_241 === true) {
2255
            return $this->finalise($result);
2256
        }
2257
        if ($_241 === false) {
2258
            return false;
2259
        }
2260
    }
2261
2262
2263
    /* ElsePart: '<%' < 'else' > '%>' Template:$TemplateMatcher? */
2264
    protected $match_ElsePart_typestack = array('ElsePart');
2265
    function match_ElsePart($stack = array())
2266
    {
2267
        $matchrule = "ElsePart";
2268
        $result = $this->construct($matchrule, $matchrule, null);
2269
        $_249 = null;
2270
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2271
            if (( $subres = $this->literal('<%') ) !== false) {
2272
                $result["text"] .= $subres;
2273
            } else {
2274
                $_249 = false;
2275
                break;
2276
            }
2277
            if (( $subres = $this->whitespace() ) !== false) {
2278
                $result["text"] .= $subres;
2279
            }
2280
            if (( $subres = $this->literal('else') ) !== false) {
2281
                $result["text"] .= $subres;
2282
            } else {
2283
                $_249 = false;
2284
                break;
2285
            }
2286
            if (( $subres = $this->whitespace() ) !== false) {
2287
                $result["text"] .= $subres;
2288
            }
2289
            if (( $subres = $this->literal('%>') ) !== false) {
2290
                $result["text"] .= $subres;
2291
            } else {
2292
                $_249 = false;
2293
                break;
2294
            }
2295
            $res_248 = $result;
2296
            $pos_248 = $this->pos;
2297
            $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher');
2298
            $key = $matcher;
2299
            $pos = $this->pos;
2300
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2301
            if ($subres !== false) {
2302
                $this->store($result, $subres, "Template");
2303
            } else {
2304
                $result = $res_248;
2305
                $this->pos = $pos_248;
2306
                unset($res_248);
2307
                unset($pos_248);
2308
            }
2309
            $_249 = true;
2310
            break;
2311
        } while (0);
2312
        if ($_249 === true) {
2313
            return $this->finalise($result);
2314
        }
2315
        if ($_249 === false) {
2316
            return false;
2317
        }
2318
    }
2319
2320
2321
    /* If: IfPart ElseIfPart* ElsePart? '<%' < 'end_if' > '%>' */
2322
    protected $match_If_typestack = array('If');
2323
    function match_If($stack = array())
2324
    {
2325
        $matchrule = "If";
2326
        $result = $this->construct($matchrule, $matchrule, null);
2327
        $_259 = null;
2328
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2329
            $matcher = 'match_'.'IfPart';
2330
            $key = $matcher;
2331
            $pos = $this->pos;
2332
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2333
            if ($subres !== false) {
2334
                $this->store($result, $subres);
2335
            } else {
2336
                $_259 = false;
2337
                break;
2338
            }
2339
            while (true) {
2340
                $res_252 = $result;
2341
                $pos_252 = $this->pos;
2342
                $matcher = 'match_'.'ElseIfPart';
2343
                $key = $matcher;
2344
                $pos = $this->pos;
2345
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2346
                if ($subres !== false) {
2347
                    $this->store($result, $subres);
2348
                } else {
2349
                    $result = $res_252;
2350
                    $this->pos = $pos_252;
2351
                    unset($res_252);
2352
                    unset($pos_252);
2353
                    break;
2354
                }
2355
            }
2356
            $res_253 = $result;
2357
            $pos_253 = $this->pos;
2358
            $matcher = 'match_'.'ElsePart';
2359
            $key = $matcher;
2360
            $pos = $this->pos;
2361
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2362
            if ($subres !== false) {
2363
                $this->store($result, $subres);
2364
            } else {
2365
                $result = $res_253;
2366
                $this->pos = $pos_253;
2367
                unset($res_253);
2368
                unset($pos_253);
2369
            }
2370
            if (( $subres = $this->literal('<%') ) !== false) {
2371
                $result["text"] .= $subres;
2372
            } else {
2373
                $_259 = false;
2374
                break;
2375
            }
2376
            if (( $subres = $this->whitespace() ) !== false) {
2377
                $result["text"] .= $subres;
2378
            }
2379
            if (( $subres = $this->literal('end_if') ) !== false) {
2380
                $result["text"] .= $subres;
2381
            } else {
2382
                $_259 = false;
2383
                break;
2384
            }
2385
            if (( $subres = $this->whitespace() ) !== false) {
2386
                $result["text"] .= $subres;
2387
            }
2388
            if (( $subres = $this->literal('%>') ) !== false) {
2389
                $result["text"] .= $subres;
2390
            } else {
2391
                $_259 = false;
2392
                break;
2393
            }
2394
            $_259 = true;
2395
            break;
2396
        } while (0);
2397
        if ($_259 === true) {
2398
            return $this->finalise($result);
2399
        }
2400
        if ($_259 === false) {
2401
            return false;
2402
        }
2403
    }
2404
2405
2406
2407
    function If_IfPart(&$res, $sub)
2408
    {
2409
        $res['php'] =
2410
            'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
2411
                (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
2412
            '}';
2413
    }
2414
2415
    function If_ElseIfPart(&$res, $sub)
2416
    {
2417
        $res['php'] .=
2418
            'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
2419
                (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
2420
            '}';
2421
    }
2422
2423
    function If_ElsePart(&$res, $sub)
2424
    {
2425
        $res['php'] .=
2426
            'else { ' . PHP_EOL .
2427
                (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
2428
            '}';
2429
    }
2430
2431
    /* Require: '<%' < 'require' [ Call:(Method:Word "(" < :CallArguments  > ")") > '%>' */
2432
    protected $match_Require_typestack = array('Require');
2433
    function match_Require($stack = array())
2434
    {
2435
        $matchrule = "Require";
2436
        $result = $this->construct($matchrule, $matchrule, null);
2437
        $_275 = null;
2438
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2439
            if (( $subres = $this->literal('<%') ) !== false) {
2440
                $result["text"] .= $subres;
2441
            } else {
2442
                $_275 = false;
2443
                break;
2444
            }
2445
            if (( $subres = $this->whitespace() ) !== false) {
2446
                $result["text"] .= $subres;
2447
            }
2448
            if (( $subres = $this->literal('require') ) !== false) {
2449
                $result["text"] .= $subres;
2450
            } else {
2451
                $_275 = false;
2452
                break;
2453
            }
2454
            if (( $subres = $this->whitespace() ) !== false) {
2455
                $result["text"] .= $subres;
2456
            } else {
2457
                $_275 = false;
2458
                break;
2459
            }
2460
            $stack[] = $result;
2461
            $result = $this->construct($matchrule, "Call");
2462
            $_271 = null;
2463
            do {
2464
                $matcher = 'match_'.'Word';
2465
                $key = $matcher;
2466
                $pos = $this->pos;
2467
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2468
                if ($subres !== false) {
2469
                    $this->store($result, $subres, "Method");
2470
                } else {
2471
                    $_271 = false;
2472
                    break;
2473
                }
2474
                if (substr($this->string, $this->pos, 1) == '(') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
2475
                    $this->pos += 1;
2476
                    $result["text"] .= '(';
2477
                } else {
2478
                    $_271 = false;
2479
                    break;
2480
                }
2481
                if (( $subres = $this->whitespace() ) !== false) {
2482
                    $result["text"] .= $subres;
2483
                }
2484
                $matcher = 'match_'.'CallArguments';
2485
                $key = $matcher;
2486
                $pos = $this->pos;
2487
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2488
                if ($subres !== false) {
2489
                    $this->store($result, $subres, "CallArguments");
2490
                } else {
2491
                    $_271 = false;
2492
                    break;
2493
                }
2494
                if (( $subres = $this->whitespace() ) !== false) {
2495
                    $result["text"] .= $subres;
2496
                }
2497
                if (substr($this->string, $this->pos, 1) == ')') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
2498
                    $this->pos += 1;
2499
                    $result["text"] .= ')';
2500
                } else {
2501
                    $_271 = false;
2502
                    break;
2503
                }
2504
                $_271 = true;
2505
                break;
2506
            } while (0);
2507
            if ($_271 === true) {
2508
                $subres = $result;
2509
                $result = array_pop($stack);
2510
                $this->store($result, $subres, 'Call');
2511
            }
2512
            if ($_271 === false) {
2513
                $result = array_pop($stack);
2514
                $_275 = false;
2515
                break;
2516
            }
2517
            if (( $subres = $this->whitespace() ) !== false) {
2518
                $result["text"] .= $subres;
2519
            }
2520
            if (( $subres = $this->literal('%>') ) !== false) {
2521
                $result["text"] .= $subres;
2522
            } else {
2523
                $_275 = false;
2524
                break;
2525
            }
2526
            $_275 = true;
2527
            break;
2528
        } while (0);
2529
        if ($_275 === true) {
2530
            return $this->finalise($result);
2531
        }
2532
        if ($_275 === false) {
2533
            return false;
2534
        }
2535
    }
2536
2537
2538
2539
    function Require_Call(&$res, $sub)
2540
    {
2541
        $requirements = '\\SilverStripe\\View\\Requirements';
2542
        $res['php'] = "{$requirements}::".$sub['Method']['text'].'('.$sub['CallArguments']['php'].');';
2543
    }
2544
2545
2546
    /* CacheBlockArgument:
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
2547
   !( "if " | "unless " )
2548
	(
2549
		:DollarMarkedLookup |
2550
		:QuotedString |
2551
		:Lookup
2552
	) */
2553
    protected $match_CacheBlockArgument_typestack = array('CacheBlockArgument');
2554
    function match_CacheBlockArgument($stack = array())
2555
    {
2556
        $matchrule = "CacheBlockArgument";
2557
        $result = $this->construct($matchrule, $matchrule, null);
2558
        $_295 = null;
2559
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_283 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2560
            $res_283 = $result;
2561
            $pos_283 = $this->pos;
2562
            $_282 = null;
2563
            do {
2564
                $_280 = null;
2565
                do {
2566
                    $res_277 = $result;
2567
                    $pos_277 = $this->pos;
2568
                    if (( $subres = $this->literal('if ') ) !== false) {
2569
                        $result["text"] .= $subres;
2570
                        $_280 = true;
2571
                        break;
2572
                    }
2573
                    $result = $res_277;
2574
                    $this->pos = $pos_277;
2575
                    if (( $subres = $this->literal('unless ') ) !== false) {
2576
                        $result["text"] .= $subres;
2577
                        $_280 = true;
2578
                        break;
2579
                    }
2580
                    $result = $res_277;
2581
                    $this->pos = $pos_277;
2582
                    $_280 = false;
2583
                    break;
2584
                } while (0);
2585
                if ($_280 === false) {
2586
                    $_282 = false;
2587
                    break;
2588
                }
2589
                $_282 = true;
2590
                break;
2591
            } while (0);
2592
            if ($_282 === true) {
2593
                $result = $res_283;
2594
                $this->pos = $pos_283;
2595
                $_295 = false;
2596
                break;
2597
            }
2598
            if ($_282 === false) {
2599
                $result = $res_283;
2600
                $this->pos = $pos_283;
2601
            }
2602
            $_293 = null;
2603
            do {
2604
                $_291 = null;
2605
                do {
2606
                    $res_284 = $result;
2607
                    $pos_284 = $this->pos;
2608
                    $matcher = 'match_'.'DollarMarkedLookup';
2609
                    $key = $matcher;
2610
                    $pos = $this->pos;
2611
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2612
                    if ($subres !== false) {
2613
                        $this->store($result, $subres, "DollarMarkedLookup");
2614
                        $_291 = true;
2615
                        break;
2616
                    }
2617
                    $result = $res_284;
2618
                    $this->pos = $pos_284;
2619
                    $_289 = null;
2620
                    do {
2621
                        $res_286 = $result;
2622
                        $pos_286 = $this->pos;
2623
                        $matcher = 'match_'.'QuotedString';
2624
                        $key = $matcher;
2625
                        $pos = $this->pos;
2626
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2627
                        if ($subres !== false) {
2628
                            $this->store($result, $subres, "QuotedString");
2629
                            $_289 = true;
2630
                            break;
2631
                        }
2632
                        $result = $res_286;
2633
                        $this->pos = $pos_286;
2634
                        $matcher = 'match_'.'Lookup';
2635
                        $key = $matcher;
2636
                        $pos = $this->pos;
2637
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2638
                        if ($subres !== false) {
2639
                            $this->store($result, $subres, "Lookup");
2640
                            $_289 = true;
2641
                            break;
2642
                        }
2643
                        $result = $res_286;
2644
                        $this->pos = $pos_286;
2645
                        $_289 = false;
2646
                        break;
2647
                    } while (0);
2648
                    if ($_289 === true) {
2649
                        $_291 = true;
2650
                        break;
2651
                    }
2652
                    $result = $res_284;
2653
                    $this->pos = $pos_284;
2654
                    $_291 = false;
2655
                    break;
2656
                } while (0);
2657
                if ($_291 === false) {
2658
                    $_293 = false;
2659
                    break;
2660
                }
2661
                $_293 = true;
2662
                break;
2663
            } while (0);
2664
            if ($_293 === false) {
2665
                $_295 = false;
2666
                break;
2667
            }
2668
            $_295 = true;
2669
            break;
2670
        } while (0);
2671
        if ($_295 === true) {
2672
            return $this->finalise($result);
2673
        }
2674
        if ($_295 === false) {
2675
            return false;
2676
        }
2677
    }
2678
2679
2680
2681
    function CacheBlockArgument_DollarMarkedLookup(&$res, $sub)
2682
    {
2683
        $res['php'] = $sub['Lookup']['php'];
2684
    }
2685
2686
    function CacheBlockArgument_QuotedString(&$res, $sub)
2687
    {
2688
        $res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'";
2689
    }
2690
2691
    function CacheBlockArgument_Lookup(&$res, $sub)
2692
    {
2693
        $res['php'] = $sub['php'];
2694
    }
2695
2696
    /* CacheBlockArguments: CacheBlockArgument ( < "," < CacheBlockArgument )* */
2697
    protected $match_CacheBlockArguments_typestack = array('CacheBlockArguments');
2698
    function match_CacheBlockArguments($stack = array())
2699
    {
2700
        $matchrule = "CacheBlockArguments";
2701
        $result = $this->construct($matchrule, $matchrule, null);
2702
        $_304 = null;
2703
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2704
            $matcher = 'match_'.'CacheBlockArgument';
2705
            $key = $matcher;
2706
            $pos = $this->pos;
2707
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2708
            if ($subres !== false) {
2709
                $this->store($result, $subres);
2710
            } else {
2711
                $_304 = false;
2712
                break;
2713
            }
2714
            while (true) {
2715
                $res_303 = $result;
2716
                $pos_303 = $this->pos;
2717
                $_302 = null;
2718
                do {
2719
                    if (( $subres = $this->whitespace() ) !== false) {
2720
                        $result["text"] .= $subres;
2721
                    }
2722
                    if (substr($this->string, $this->pos, 1) == ',') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
2723
                        $this->pos += 1;
2724
                        $result["text"] .= ',';
2725
                    } else {
2726
                        $_302 = false;
2727
                        break;
2728
                    }
2729
                    if (( $subres = $this->whitespace() ) !== false) {
2730
                        $result["text"] .= $subres;
2731
                    }
2732
                    $matcher = 'match_'.'CacheBlockArgument';
2733
                    $key = $matcher;
2734
                    $pos = $this->pos;
2735
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2736
                    if ($subres !== false) {
2737
                        $this->store($result, $subres);
2738
                    } else {
2739
                        $_302 = false;
2740
                        break;
2741
                    }
2742
                    $_302 = true;
2743
                    break;
2744
                } while (0);
2745
                if ($_302 === false) {
2746
                    $result = $res_303;
2747
                    $this->pos = $pos_303;
2748
                    unset($res_303);
2749
                    unset($pos_303);
2750
                    break;
2751
                }
2752
            }
2753
            $_304 = true;
2754
            break;
2755
        } while (0);
2756
        if ($_304 === true) {
2757
            return $this->finalise($result);
2758
        }
2759
        if ($_304 === false) {
2760
            return false;
2761
        }
2762
    }
2763
2764
2765
2766
    function CacheBlockArguments_CacheBlockArgument(&$res, $sub)
2767
    {
2768
        if (!empty($res['php'])) {
2769
            $res['php'] .= ".'_'.";
2770
        } else {
2771
            $res['php'] = '';
2772
        }
2773
2774
        $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
2775
    }
2776
2777
    /* CacheBlockTemplate: (Comment | Translate | If | Require |    OldI18NTag | Include | ClosedBlock |
2778
	OpenBlock | MalformedBlock | Injection | Text)+ */
2779
    protected $match_CacheBlockTemplate_typestack = array('CacheBlockTemplate','Template');
2780
    function match_CacheBlockTemplate($stack = array())
2781
    {
2782
        $matchrule = "CacheBlockTemplate";
2783
        $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'CacheRestrictedTemplate'));
2784
        $count = 0;
2785
        while (true) {
2786
            $res_348 = $result;
2787
            $pos_348 = $this->pos;
2788
            $_347 = null;
2789
            do {
0 ignored issues
show
Unused Code introduced by
do { $_345 = null; ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
2790
                $_345 = null;
2791
                do {
2792
                    $res_306 = $result;
2793
                    $pos_306 = $this->pos;
2794
                    $matcher = 'match_'.'Comment';
2795
                    $key = $matcher;
2796
                    $pos = $this->pos;
2797
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2798
                    if ($subres !== false) {
2799
                        $this->store($result, $subres);
2800
                        $_345 = true;
2801
                        break;
2802
                    }
2803
                    $result = $res_306;
2804
                    $this->pos = $pos_306;
2805
                    $_343 = null;
2806
                    do {
2807
                        $res_308 = $result;
2808
                        $pos_308 = $this->pos;
2809
                        $matcher = 'match_'.'Translate';
2810
                        $key = $matcher;
2811
                        $pos = $this->pos;
2812
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2813
                        if ($subres !== false) {
2814
                            $this->store($result, $subres);
2815
                            $_343 = true;
2816
                            break;
2817
                        }
2818
                        $result = $res_308;
2819
                        $this->pos = $pos_308;
2820
                        $_341 = null;
2821
                        do {
2822
                            $res_310 = $result;
2823
                            $pos_310 = $this->pos;
2824
                            $matcher = 'match_'.'If';
2825
                            $key = $matcher;
2826
                            $pos = $this->pos;
2827
                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2828
                            if ($subres !== false) {
2829
                                $this->store($result, $subres);
2830
                                $_341 = true;
2831
                                break;
2832
                            }
2833
                            $result = $res_310;
2834
                            $this->pos = $pos_310;
2835
                            $_339 = null;
2836
                            do {
2837
                                $res_312 = $result;
2838
                                $pos_312 = $this->pos;
2839
                                $matcher = 'match_'.'Require';
2840
                                $key = $matcher;
2841
                                $pos = $this->pos;
2842
                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2843
                                if ($subres !== false) {
2844
                                    $this->store($result, $subres);
2845
                                    $_339 = true;
2846
                                    break;
2847
                                }
2848
                                $result = $res_312;
2849
                                $this->pos = $pos_312;
2850
                                $_337 = null;
2851
                                do {
2852
                                    $res_314 = $result;
2853
                                    $pos_314 = $this->pos;
2854
                                    $matcher = 'match_'.'OldI18NTag';
2855
                                    $key = $matcher;
2856
                                    $pos = $this->pos;
2857
                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2858
                                    if ($subres !== false) {
2859
                                        $this->store($result, $subres);
2860
                                        $_337 = true;
2861
                                        break;
2862
                                    }
2863
                                    $result = $res_314;
2864
                                    $this->pos = $pos_314;
2865
                                    $_335 = null;
2866
                                    do {
2867
                                        $res_316 = $result;
2868
                                        $pos_316 = $this->pos;
2869
                                        $matcher = 'match_'.'Include';
2870
                                        $key = $matcher;
2871
                                        $pos = $this->pos;
2872
                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2873
                                        if ($subres !== false) {
2874
                                            $this->store($result, $subres);
2875
                                            $_335 = true;
2876
                                            break;
2877
                                        }
2878
                                        $result = $res_316;
2879
                                        $this->pos = $pos_316;
2880
                                        $_333 = null;
2881
                                        do {
2882
                                            $res_318 = $result;
2883
                                            $pos_318 = $this->pos;
2884
                                            $matcher = 'match_'.'ClosedBlock';
2885
                                            $key = $matcher;
2886
                                            $pos = $this->pos;
2887
                                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2888
                                            if ($subres !== false) {
2889
                                                $this->store($result, $subres);
2890
                                                $_333 = true;
2891
                                                break;
2892
                                            }
2893
                                            $result = $res_318;
2894
                                            $this->pos = $pos_318;
2895
                                            $_331 = null;
2896
                                            do {
2897
                                                $res_320 = $result;
2898
                                                $pos_320 = $this->pos;
2899
                                                $matcher = 'match_'.'OpenBlock';
2900
                                                $key = $matcher;
2901
                                                $pos = $this->pos;
2902
                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2903
                                                if ($subres !== false) {
2904
                                                    $this->store($result, $subres);
2905
                                                    $_331 = true;
2906
                                                    break;
2907
                                                }
2908
                                                $result = $res_320;
2909
                                                $this->pos = $pos_320;
2910
                                                $_329 = null;
2911
                                                do {
2912
                                                    $res_322 = $result;
2913
                                                    $pos_322 = $this->pos;
2914
                                                    $matcher = 'match_'.'MalformedBlock';
2915
                                                    $key = $matcher;
2916
                                                    $pos = $this->pos;
2917
                                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2918
                                                    if ($subres !== false) {
2919
                                                        $this->store($result, $subres);
2920
                                                        $_329 = true;
2921
                                                        break;
2922
                                                    }
2923
                                                    $result = $res_322;
2924
                                                    $this->pos = $pos_322;
2925
                                                    $_327 = null;
2926
                                                    do {
2927
                                                        $res_324 = $result;
2928
                                                        $pos_324 = $this->pos;
2929
                                                        $matcher = 'match_'.'Injection';
2930
                                                        $key = $matcher;
2931
                                                        $pos = $this->pos;
2932
                                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2933
                                                        if ($subres !== false) {
2934
                                                            $this->store($result, $subres);
2935
                                                            $_327 = true;
2936
                                                            break;
2937
                                                        }
2938
                                                        $result = $res_324;
2939
                                                        $this->pos = $pos_324;
2940
                                                        $matcher = 'match_'.'Text';
2941
                                                        $key = $matcher;
2942
                                                        $pos = $this->pos;
2943
                                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
2944
                                                        if ($subres !== false) {
2945
                                                            $this->store($result, $subres);
2946
                                                            $_327 = true;
2947
                                                            break;
2948
                                                        }
2949
                                                        $result = $res_324;
2950
                                                        $this->pos = $pos_324;
2951
                                                        $_327 = false;
2952
                                                        break;
2953
                                                    } while (0);
2954
                                                    if ($_327 === true) {
2955
                                                        $_329 = true;
2956
                                                        break;
2957
                                                    }
2958
                                                    $result = $res_322;
2959
                                                    $this->pos = $pos_322;
2960
                                                    $_329 = false;
2961
                                                    break;
2962
                                                } while (0);
2963
                                                if ($_329 === true) {
2964
                                                    $_331 = true;
2965
                                                    break;
2966
                                                }
2967
                                                $result = $res_320;
2968
                                                $this->pos = $pos_320;
2969
                                                $_331 = false;
2970
                                                break;
2971
                                            } while (0);
2972
                                            if ($_331 === true) {
2973
                                                $_333 = true;
2974
                                                break;
2975
                                            }
2976
                                            $result = $res_318;
2977
                                            $this->pos = $pos_318;
2978
                                            $_333 = false;
2979
                                            break;
2980
                                        } while (0);
2981
                                        if ($_333 === true) {
2982
                                            $_335 = true;
2983
                                            break;
2984
                                        }
2985
                                        $result = $res_316;
2986
                                        $this->pos = $pos_316;
2987
                                        $_335 = false;
2988
                                        break;
2989
                                    } while (0);
2990
                                    if ($_335 === true) {
2991
                                        $_337 = true;
2992
                                        break;
2993
                                    }
2994
                                    $result = $res_314;
2995
                                    $this->pos = $pos_314;
2996
                                    $_337 = false;
2997
                                    break;
2998
                                } while (0);
2999
                                if ($_337 === true) {
3000
                                    $_339 = true;
3001
                                    break;
3002
                                }
3003
                                $result = $res_312;
3004
                                $this->pos = $pos_312;
3005
                                $_339 = false;
3006
                                break;
3007
                            } while (0);
3008
                            if ($_339 === true) {
3009
                                $_341 = true;
3010
                                break;
3011
                            }
3012
                            $result = $res_310;
3013
                            $this->pos = $pos_310;
3014
                            $_341 = false;
3015
                            break;
3016
                        } while (0);
3017
                        if ($_341 === true) {
3018
                            $_343 = true;
3019
                            break;
3020
                        }
3021
                        $result = $res_308;
3022
                        $this->pos = $pos_308;
3023
                        $_343 = false;
3024
                        break;
3025
                    } while (0);
3026
                    if ($_343 === true) {
3027
                        $_345 = true;
3028
                        break;
3029
                    }
3030
                    $result = $res_306;
3031
                    $this->pos = $pos_306;
3032
                    $_345 = false;
3033
                    break;
3034
                } while (0);
3035
                if ($_345 === false) {
3036
                    $_347 = false;
3037
                    break;
3038
                }
3039
                $_347 = true;
3040
                break;
3041
            } while (0);
3042
            if ($_347 === false) {
3043
                $result = $res_348;
3044
                $this->pos = $pos_348;
3045
                unset($res_348);
3046
                unset($pos_348);
3047
                break;
3048
            }
3049
            $count += 1;
3050
        }
3051
        if ($count > 0) {
3052
            return $this->finalise($result);
3053
        } else {
3054
            return false;
3055
        }
3056
    }
3057
3058
3059
3060
3061
    /* UncachedBlock:
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3062
	'<%' < "uncached" < CacheBlockArguments? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>'
3063
		Template:$TemplateMatcher?
3064
		'<%' < 'end_' ("uncached"|"cached"|"cacheblock") > '%>' */
3065
    protected $match_UncachedBlock_typestack = array('UncachedBlock');
3066
    function match_UncachedBlock($stack = array())
3067
    {
3068
        $matchrule = "UncachedBlock";
3069
        $result = $this->construct($matchrule, $matchrule, null);
3070
        $_385 = null;
3071
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
3072
            if (( $subres = $this->literal('<%') ) !== false) {
3073
                $result["text"] .= $subres;
3074
            } else {
3075
                $_385 = false;
3076
                break;
3077
            }
3078
            if (( $subres = $this->whitespace() ) !== false) {
3079
                $result["text"] .= $subres;
3080
            }
3081
            if (( $subres = $this->literal('uncached') ) !== false) {
3082
                $result["text"] .= $subres;
3083
            } else {
3084
                $_385 = false;
3085
                break;
3086
            }
3087
            if (( $subres = $this->whitespace() ) !== false) {
3088
                $result["text"] .= $subres;
3089
            }
3090
            $res_353 = $result;
3091
            $pos_353 = $this->pos;
3092
            $matcher = 'match_'.'CacheBlockArguments';
3093
            $key = $matcher;
3094
            $pos = $this->pos;
3095
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3096
            if ($subres !== false) {
3097
                $this->store($result, $subres);
3098
            } else {
3099
                $result = $res_353;
3100
                $this->pos = $pos_353;
3101
                unset($res_353);
3102
                unset($pos_353);
3103
            }
3104
            $res_365 = $result;
3105
            $pos_365 = $this->pos;
3106
            $_364 = null;
3107
            do {
3108
                if (( $subres = $this->whitespace() ) !== false) {
3109
                    $result["text"] .= $subres;
3110
                }
3111
                $stack[] = $result;
3112
                $result = $this->construct($matchrule, "Conditional");
3113
                $_360 = null;
3114
                do {
3115
                    $_358 = null;
3116
                    do {
3117
                        $res_355 = $result;
3118
                        $pos_355 = $this->pos;
3119
                        if (( $subres = $this->literal('if') ) !== false) {
3120
                            $result["text"] .= $subres;
3121
                            $_358 = true;
3122
                            break;
3123
                        }
3124
                        $result = $res_355;
3125
                        $this->pos = $pos_355;
3126
                        if (( $subres = $this->literal('unless') ) !== false) {
3127
                            $result["text"] .= $subres;
3128
                            $_358 = true;
3129
                            break;
3130
                        }
3131
                        $result = $res_355;
3132
                        $this->pos = $pos_355;
3133
                        $_358 = false;
3134
                        break;
3135
                    } while (0);
3136
                    if ($_358 === false) {
3137
                        $_360 = false;
3138
                        break;
3139
                    }
3140
                    $_360 = true;
3141
                    break;
3142
                } while (0);
3143
                if ($_360 === true) {
3144
                    $subres = $result;
3145
                    $result = array_pop($stack);
3146
                    $this->store($result, $subres, 'Conditional');
3147
                }
3148
                if ($_360 === false) {
3149
                    $result = array_pop($stack);
3150
                    $_364 = false;
3151
                    break;
3152
                }
3153
                if (( $subres = $this->whitespace() ) !== false) {
3154
                    $result["text"] .= $subres;
3155
                }
3156
                $matcher = 'match_'.'IfArgument';
3157
                $key = $matcher;
3158
                $pos = $this->pos;
3159
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3160
                if ($subres !== false) {
3161
                    $this->store($result, $subres, "Condition");
3162
                } else {
3163
                    $_364 = false;
3164
                    break;
3165
                }
3166
                $_364 = true;
3167
                break;
3168
            } while (0);
3169
            if ($_364 === false) {
3170
                $result = $res_365;
3171
                $this->pos = $pos_365;
3172
                unset($res_365);
3173
                unset($pos_365);
3174
            }
3175
            if (( $subres = $this->whitespace() ) !== false) {
3176
                $result["text"] .= $subres;
3177
            }
3178
            if (( $subres = $this->literal('%>') ) !== false) {
3179
                $result["text"] .= $subres;
3180
            } else {
3181
                $_385 = false;
3182
                break;
3183
            }
3184
            $res_368 = $result;
3185
            $pos_368 = $this->pos;
3186
            $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher');
3187
            $key = $matcher;
3188
            $pos = $this->pos;
3189
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3190
            if ($subres !== false) {
3191
                $this->store($result, $subres, "Template");
3192
            } else {
3193
                $result = $res_368;
3194
                $this->pos = $pos_368;
3195
                unset($res_368);
3196
                unset($pos_368);
3197
            }
3198
            if (( $subres = $this->literal('<%') ) !== false) {
3199
                $result["text"] .= $subres;
3200
            } else {
3201
                $_385 = false;
3202
                break;
3203
            }
3204
            if (( $subres = $this->whitespace() ) !== false) {
3205
                $result["text"] .= $subres;
3206
            }
3207
            if (( $subres = $this->literal('end_') ) !== false) {
3208
                $result["text"] .= $subres;
3209
            } else {
3210
                $_385 = false;
3211
                break;
3212
            }
3213
            $_381 = null;
3214
            do {
3215
                $_379 = null;
3216
                do {
3217
                    $res_372 = $result;
3218
                    $pos_372 = $this->pos;
3219
                    if (( $subres = $this->literal('uncached') ) !== false) {
3220
                        $result["text"] .= $subres;
3221
                        $_379 = true;
3222
                        break;
3223
                    }
3224
                    $result = $res_372;
3225
                    $this->pos = $pos_372;
3226
                    $_377 = null;
3227
                    do {
3228
                        $res_374 = $result;
3229
                        $pos_374 = $this->pos;
3230
                        if (( $subres = $this->literal('cached') ) !== false) {
3231
                            $result["text"] .= $subres;
3232
                            $_377 = true;
3233
                            break;
3234
                        }
3235
                        $result = $res_374;
3236
                        $this->pos = $pos_374;
3237
                        if (( $subres = $this->literal('cacheblock') ) !== false) {
3238
                            $result["text"] .= $subres;
3239
                            $_377 = true;
3240
                            break;
3241
                        }
3242
                        $result = $res_374;
3243
                        $this->pos = $pos_374;
3244
                        $_377 = false;
3245
                        break;
3246
                    } while (0);
3247
                    if ($_377 === true) {
3248
                        $_379 = true;
3249
                        break;
3250
                    }
3251
                    $result = $res_372;
3252
                    $this->pos = $pos_372;
3253
                    $_379 = false;
3254
                    break;
3255
                } while (0);
3256
                if ($_379 === false) {
3257
                    $_381 = false;
3258
                    break;
3259
                }
3260
                $_381 = true;
3261
                break;
3262
            } while (0);
3263
            if ($_381 === false) {
3264
                $_385 = false;
3265
                break;
3266
            }
3267
            if (( $subres = $this->whitespace() ) !== false) {
3268
                $result["text"] .= $subres;
3269
            }
3270
            if (( $subres = $this->literal('%>') ) !== false) {
3271
                $result["text"] .= $subres;
3272
            } else {
3273
                $_385 = false;
3274
                break;
3275
            }
3276
            $_385 = true;
3277
            break;
3278
        } while (0);
3279
        if ($_385 === true) {
3280
            return $this->finalise($result);
3281
        }
3282
        if ($_385 === false) {
3283
            return false;
3284
        }
3285
    }
3286
3287
3288
3289
    function UncachedBlock_Template(&$res, $sub)
3290
    {
3291
        $res['php'] = $sub['php'];
3292
    }
3293
3294
    /* CacheRestrictedTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
3295
	OpenBlock | MalformedBlock | Injection | Text)+ */
3296
    protected $match_CacheRestrictedTemplate_typestack = array('CacheRestrictedTemplate','Template');
3297
    function match_CacheRestrictedTemplate($stack = array())
3298
    {
3299
        $matchrule = "CacheRestrictedTemplate";
3300
        $result = $this->construct($matchrule, $matchrule, null);
3301
        $count = 0;
3302
        while (true) {
3303
            $res_437 = $result;
3304
            $pos_437 = $this->pos;
3305
            $_436 = null;
3306
            do {
0 ignored issues
show
Unused Code introduced by
do { $_434 = null; ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
3307
                $_434 = null;
3308
                do {
3309
                    $res_387 = $result;
3310
                    $pos_387 = $this->pos;
3311
                    $matcher = 'match_'.'Comment';
3312
                    $key = $matcher;
3313
                    $pos = $this->pos;
3314
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3315
                    if ($subres !== false) {
3316
                        $this->store($result, $subres);
3317
                        $_434 = true;
3318
                        break;
3319
                    }
3320
                    $result = $res_387;
3321
                    $this->pos = $pos_387;
3322
                    $_432 = null;
3323
                    do {
3324
                        $res_389 = $result;
3325
                        $pos_389 = $this->pos;
3326
                        $matcher = 'match_'.'Translate';
3327
                        $key = $matcher;
3328
                        $pos = $this->pos;
3329
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3330
                        if ($subres !== false) {
3331
                            $this->store($result, $subres);
3332
                            $_432 = true;
3333
                            break;
3334
                        }
3335
                        $result = $res_389;
3336
                        $this->pos = $pos_389;
3337
                        $_430 = null;
3338
                        do {
3339
                            $res_391 = $result;
3340
                            $pos_391 = $this->pos;
3341
                            $matcher = 'match_'.'If';
3342
                            $key = $matcher;
3343
                            $pos = $this->pos;
3344
                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3345
                            if ($subres !== false) {
3346
                                $this->store($result, $subres);
3347
                                $_430 = true;
3348
                                break;
3349
                            }
3350
                            $result = $res_391;
3351
                            $this->pos = $pos_391;
3352
                            $_428 = null;
3353
                            do {
3354
                                $res_393 = $result;
3355
                                $pos_393 = $this->pos;
3356
                                $matcher = 'match_'.'Require';
3357
                                $key = $matcher;
3358
                                $pos = $this->pos;
3359
                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3360
                                if ($subres !== false) {
3361
                                    $this->store($result, $subres);
3362
                                    $_428 = true;
3363
                                    break;
3364
                                }
3365
                                $result = $res_393;
3366
                                $this->pos = $pos_393;
3367
                                $_426 = null;
3368
                                do {
3369
                                    $res_395 = $result;
3370
                                    $pos_395 = $this->pos;
3371
                                    $matcher = 'match_'.'CacheBlock';
3372
                                    $key = $matcher;
3373
                                    $pos = $this->pos;
3374
                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3375
                                    if ($subres !== false) {
3376
                                        $this->store($result, $subres);
3377
                                        $_426 = true;
3378
                                        break;
3379
                                    }
3380
                                    $result = $res_395;
3381
                                    $this->pos = $pos_395;
3382
                                    $_424 = null;
3383
                                    do {
3384
                                        $res_397 = $result;
3385
                                        $pos_397 = $this->pos;
3386
                                        $matcher = 'match_'.'UncachedBlock';
3387
                                        $key = $matcher;
3388
                                        $pos = $this->pos;
3389
                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3390
                                        if ($subres !== false) {
3391
                                            $this->store($result, $subres);
3392
                                            $_424 = true;
3393
                                            break;
3394
                                        }
3395
                                        $result = $res_397;
3396
                                        $this->pos = $pos_397;
3397
                                        $_422 = null;
3398
                                        do {
3399
                                            $res_399 = $result;
3400
                                            $pos_399 = $this->pos;
3401
                                            $matcher = 'match_'.'OldI18NTag';
3402
                                            $key = $matcher;
3403
                                            $pos = $this->pos;
3404
                                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3405
                                            if ($subres !== false) {
3406
                                                $this->store($result, $subres);
3407
                                                $_422 = true;
3408
                                                break;
3409
                                            }
3410
                                            $result = $res_399;
3411
                                            $this->pos = $pos_399;
3412
                                            $_420 = null;
3413
                                            do {
3414
                                                $res_401 = $result;
3415
                                                $pos_401 = $this->pos;
3416
                                                $matcher = 'match_'.'Include';
3417
                                                $key = $matcher;
3418
                                                $pos = $this->pos;
3419
                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3420
                                                if ($subres !== false) {
3421
                                                    $this->store($result, $subres);
3422
                                                    $_420 = true;
3423
                                                    break;
3424
                                                }
3425
                                                $result = $res_401;
3426
                                                $this->pos = $pos_401;
3427
                                                $_418 = null;
3428
                                                do {
3429
                                                    $res_403 = $result;
3430
                                                    $pos_403 = $this->pos;
3431
                                                    $matcher = 'match_'.'ClosedBlock';
3432
                                                    $key = $matcher;
3433
                                                    $pos = $this->pos;
3434
                                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3435
                                                    if ($subres !== false) {
3436
                                                        $this->store($result, $subres);
3437
                                                        $_418 = true;
3438
                                                        break;
3439
                                                    }
3440
                                                    $result = $res_403;
3441
                                                    $this->pos = $pos_403;
3442
                                                    $_416 = null;
3443
                                                    do {
3444
                                                        $res_405 = $result;
3445
                                                        $pos_405 = $this->pos;
3446
                                                        $matcher = 'match_'.'OpenBlock';
3447
                                                        $key = $matcher;
3448
                                                        $pos = $this->pos;
3449
                                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3450
                                                        if ($subres !== false) {
3451
                                                            $this->store($result, $subres);
3452
                                                            $_416 = true;
3453
                                                            break;
3454
                                                        }
3455
                                                        $result = $res_405;
3456
                                                        $this->pos = $pos_405;
3457
                                                        $_414 = null;
3458
                                                        do {
3459
                                                            $res_407 = $result;
3460
                                                            $pos_407 = $this->pos;
3461
                                                            $matcher = 'match_'.'MalformedBlock';
3462
                                                            $key = $matcher;
3463
                                                            $pos = $this->pos;
3464
                                                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3465
                                                            if ($subres !== false) {
3466
                                                                $this->store($result, $subres);
3467
                                                                $_414 = true;
3468
                                                                break;
3469
                                                            }
3470
                                                            $result = $res_407;
3471
                                                            $this->pos = $pos_407;
3472
                                                            $_412 = null;
3473
                                                            do {
3474
                                                                $res_409 = $result;
3475
                                                                $pos_409 = $this->pos;
3476
                                                                $matcher = 'match_'.'Injection';
3477
                                                                $key = $matcher;
3478
                                                                $pos = $this->pos;
3479
                                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3480
                                                                if ($subres !== false) {
3481
                                                                    $this->store($result, $subres);
3482
                                                                    $_412 = true;
3483
                                                                    break;
3484
                                                                }
3485
                                                                $result = $res_409;
3486
                                                                $this->pos = $pos_409;
3487
                                                                $matcher = 'match_'.'Text';
3488
                                                                $key = $matcher;
3489
                                                                $pos = $this->pos;
3490
                                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3491
                                                                if ($subres !== false) {
3492
                                                                    $this->store($result, $subres);
3493
                                                                    $_412 = true;
3494
                                                                    break;
3495
                                                                }
3496
                                                                $result = $res_409;
3497
                                                                $this->pos = $pos_409;
3498
                                                                $_412 = false;
3499
                                                                break;
3500
                                                            } while (0);
3501
                                                            if ($_412 === true) {
3502
                                                                $_414 = true;
3503
                                                                break;
3504
                                                            }
3505
                                                            $result = $res_407;
3506
                                                            $this->pos = $pos_407;
3507
                                                            $_414 = false;
3508
                                                            break;
3509
                                                        } while (0);
3510
                                                        if ($_414 === true) {
3511
                                                            $_416 = true;
3512
                                                            break;
3513
                                                        }
3514
                                                        $result = $res_405;
3515
                                                        $this->pos = $pos_405;
3516
                                                        $_416 = false;
3517
                                                        break;
3518
                                                    } while (0);
3519
                                                    if ($_416 === true) {
3520
                                                        $_418 = true;
3521
                                                        break;
3522
                                                    }
3523
                                                    $result = $res_403;
3524
                                                    $this->pos = $pos_403;
3525
                                                    $_418 = false;
3526
                                                    break;
3527
                                                } while (0);
3528
                                                if ($_418 === true) {
3529
                                                    $_420 = true;
3530
                                                    break;
3531
                                                }
3532
                                                $result = $res_401;
3533
                                                $this->pos = $pos_401;
3534
                                                $_420 = false;
3535
                                                break;
3536
                                            } while (0);
3537
                                            if ($_420 === true) {
3538
                                                $_422 = true;
3539
                                                break;
3540
                                            }
3541
                                            $result = $res_399;
3542
                                            $this->pos = $pos_399;
3543
                                            $_422 = false;
3544
                                            break;
3545
                                        } while (0);
3546
                                        if ($_422 === true) {
3547
                                            $_424 = true;
3548
                                            break;
3549
                                        }
3550
                                        $result = $res_397;
3551
                                        $this->pos = $pos_397;
3552
                                        $_424 = false;
3553
                                        break;
3554
                                    } while (0);
3555
                                    if ($_424 === true) {
3556
                                        $_426 = true;
3557
                                        break;
3558
                                    }
3559
                                    $result = $res_395;
3560
                                    $this->pos = $pos_395;
3561
                                    $_426 = false;
3562
                                    break;
3563
                                } while (0);
3564
                                if ($_426 === true) {
3565
                                    $_428 = true;
3566
                                    break;
3567
                                }
3568
                                $result = $res_393;
3569
                                $this->pos = $pos_393;
3570
                                $_428 = false;
3571
                                break;
3572
                            } while (0);
3573
                            if ($_428 === true) {
3574
                                $_430 = true;
3575
                                break;
3576
                            }
3577
                            $result = $res_391;
3578
                            $this->pos = $pos_391;
3579
                            $_430 = false;
3580
                            break;
3581
                        } while (0);
3582
                        if ($_430 === true) {
3583
                            $_432 = true;
3584
                            break;
3585
                        }
3586
                        $result = $res_389;
3587
                        $this->pos = $pos_389;
3588
                        $_432 = false;
3589
                        break;
3590
                    } while (0);
3591
                    if ($_432 === true) {
3592
                        $_434 = true;
3593
                        break;
3594
                    }
3595
                    $result = $res_387;
3596
                    $this->pos = $pos_387;
3597
                    $_434 = false;
3598
                    break;
3599
                } while (0);
3600
                if ($_434 === false) {
3601
                    $_436 = false;
3602
                    break;
3603
                }
3604
                $_436 = true;
3605
                break;
3606
            } while (0);
3607
            if ($_436 === false) {
3608
                $result = $res_437;
3609
                $this->pos = $pos_437;
3610
                unset($res_437);
3611
                unset($pos_437);
3612
                break;
3613
            }
3614
            $count += 1;
3615
        }
3616
        if ($count > 0) {
3617
            return $this->finalise($result);
3618
        } else {
3619
            return false;
3620
        }
3621
    }
3622
3623
3624
3625
    function CacheRestrictedTemplate_CacheBlock(&$res, $sub)
0 ignored issues
show
Unused Code introduced by
The parameter $res is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $sub is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
3626
    {
3627
        throw new SSTemplateParseException('You cant have cache blocks nested within with, loop or control blocks ' .
3628
            'that are within cache blocks', $this);
3629
    }
3630
3631
    function CacheRestrictedTemplate_UncachedBlock(&$res, $sub)
0 ignored issues
show
Unused Code introduced by
The parameter $res is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $sub is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
3632
    {
3633
        throw new SSTemplateParseException('You cant have uncache blocks nested within with, loop or control blocks ' .
3634
            'that are within cache blocks', $this);
3635
    }
3636
3637
    /* CacheBlock:
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3638
	'<%' < CacheTag:("cached"|"cacheblock") < (CacheBlockArguments)? ( < Conditional:("if"|"unless") >
3639
	Condition:IfArgument )? > '%>'
3640
		(CacheBlock | UncachedBlock | CacheBlockTemplate)*
3641
	'<%' < 'end_' ("cached"|"uncached"|"cacheblock") > '%>' */
3642
    protected $match_CacheBlock_typestack = array('CacheBlock');
3643
    function match_CacheBlock($stack = array())
3644
    {
3645
        $matchrule = "CacheBlock";
3646
        $result = $this->construct($matchrule, $matchrule, null);
3647
        $_492 = null;
3648
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
3649
            if (( $subres = $this->literal('<%') ) !== false) {
3650
                $result["text"] .= $subres;
3651
            } else {
3652
                $_492 = false;
3653
                break;
3654
            }
3655
            if (( $subres = $this->whitespace() ) !== false) {
3656
                $result["text"] .= $subres;
3657
            }
3658
            $stack[] = $result;
3659
            $result = $this->construct($matchrule, "CacheTag");
3660
            $_445 = null;
3661
            do {
3662
                $_443 = null;
3663
                do {
3664
                    $res_440 = $result;
3665
                    $pos_440 = $this->pos;
3666
                    if (( $subres = $this->literal('cached') ) !== false) {
3667
                        $result["text"] .= $subres;
3668
                        $_443 = true;
3669
                        break;
3670
                    }
3671
                    $result = $res_440;
3672
                    $this->pos = $pos_440;
3673
                    if (( $subres = $this->literal('cacheblock') ) !== false) {
3674
                        $result["text"] .= $subres;
3675
                        $_443 = true;
3676
                        break;
3677
                    }
3678
                    $result = $res_440;
3679
                    $this->pos = $pos_440;
3680
                    $_443 = false;
3681
                    break;
3682
                } while (0);
3683
                if ($_443 === false) {
3684
                    $_445 = false;
3685
                    break;
3686
                }
3687
                $_445 = true;
3688
                break;
3689
            } while (0);
3690
            if ($_445 === true) {
3691
                $subres = $result;
3692
                $result = array_pop($stack);
3693
                $this->store($result, $subres, 'CacheTag');
3694
            }
3695
            if ($_445 === false) {
3696
                $result = array_pop($stack);
3697
                $_492 = false;
3698
                break;
3699
            }
3700
            if (( $subres = $this->whitespace() ) !== false) {
3701
                $result["text"] .= $subres;
3702
            }
3703
            $res_450 = $result;
3704
            $pos_450 = $this->pos;
3705
            $_449 = null;
3706
            do {
3707
                $matcher = 'match_'.'CacheBlockArguments';
3708
                $key = $matcher;
3709
                $pos = $this->pos;
3710
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3711
                if ($subres !== false) {
3712
                    $this->store($result, $subres);
3713
                } else {
3714
                    $_449 = false;
3715
                    break;
3716
                }
3717
                $_449 = true;
3718
                break;
3719
            } while (0);
3720
            if ($_449 === false) {
3721
                $result = $res_450;
3722
                $this->pos = $pos_450;
3723
                unset($res_450);
3724
                unset($pos_450);
3725
            }
3726
            $res_462 = $result;
3727
            $pos_462 = $this->pos;
3728
            $_461 = null;
3729
            do {
3730
                if (( $subres = $this->whitespace() ) !== false) {
3731
                    $result["text"] .= $subres;
3732
                }
3733
                $stack[] = $result;
3734
                $result = $this->construct($matchrule, "Conditional");
3735
                $_457 = null;
3736
                do {
3737
                    $_455 = null;
3738
                    do {
3739
                        $res_452 = $result;
3740
                        $pos_452 = $this->pos;
3741
                        if (( $subres = $this->literal('if') ) !== false) {
3742
                            $result["text"] .= $subres;
3743
                            $_455 = true;
3744
                            break;
3745
                        }
3746
                        $result = $res_452;
3747
                        $this->pos = $pos_452;
3748
                        if (( $subres = $this->literal('unless') ) !== false) {
3749
                            $result["text"] .= $subres;
3750
                            $_455 = true;
3751
                            break;
3752
                        }
3753
                        $result = $res_452;
3754
                        $this->pos = $pos_452;
3755
                        $_455 = false;
3756
                        break;
3757
                    } while (0);
3758
                    if ($_455 === false) {
3759
                        $_457 = false;
3760
                        break;
3761
                    }
3762
                    $_457 = true;
3763
                    break;
3764
                } while (0);
3765
                if ($_457 === true) {
3766
                    $subres = $result;
3767
                    $result = array_pop($stack);
3768
                    $this->store($result, $subres, 'Conditional');
3769
                }
3770
                if ($_457 === false) {
3771
                    $result = array_pop($stack);
3772
                    $_461 = false;
3773
                    break;
3774
                }
3775
                if (( $subres = $this->whitespace() ) !== false) {
3776
                    $result["text"] .= $subres;
3777
                }
3778
                $matcher = 'match_'.'IfArgument';
3779
                $key = $matcher;
3780
                $pos = $this->pos;
3781
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3782
                if ($subres !== false) {
3783
                    $this->store($result, $subres, "Condition");
3784
                } else {
3785
                    $_461 = false;
3786
                    break;
3787
                }
3788
                $_461 = true;
3789
                break;
3790
            } while (0);
3791
            if ($_461 === false) {
3792
                $result = $res_462;
3793
                $this->pos = $pos_462;
3794
                unset($res_462);
3795
                unset($pos_462);
3796
            }
3797
            if (( $subres = $this->whitespace() ) !== false) {
3798
                $result["text"] .= $subres;
3799
            }
3800
            if (( $subres = $this->literal('%>') ) !== false) {
3801
                $result["text"] .= $subres;
3802
            } else {
3803
                $_492 = false;
3804
                break;
3805
            }
3806
            while (true) {
3807
                $res_475 = $result;
3808
                $pos_475 = $this->pos;
3809
                $_474 = null;
3810
                do {
3811
                    $_472 = null;
3812
                    do {
3813
                        $res_465 = $result;
3814
                        $pos_465 = $this->pos;
3815
                        $matcher = 'match_'.'CacheBlock';
3816
                        $key = $matcher;
3817
                        $pos = $this->pos;
3818
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3819
                        if ($subres !== false) {
3820
                            $this->store($result, $subres);
3821
                            $_472 = true;
3822
                            break;
3823
                        }
3824
                        $result = $res_465;
3825
                        $this->pos = $pos_465;
3826
                        $_470 = null;
3827
                        do {
3828
                            $res_467 = $result;
3829
                            $pos_467 = $this->pos;
3830
                            $matcher = 'match_'.'UncachedBlock';
3831
                            $key = $matcher;
3832
                            $pos = $this->pos;
3833
                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3834
                            if ($subres !== false) {
3835
                                $this->store($result, $subres);
3836
                                $_470 = true;
3837
                                break;
3838
                            }
3839
                            $result = $res_467;
3840
                            $this->pos = $pos_467;
3841
                            $matcher = 'match_'.'CacheBlockTemplate';
3842
                            $key = $matcher;
3843
                            $pos = $this->pos;
3844
                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
3845
                            if ($subres !== false) {
3846
                                $this->store($result, $subres);
3847
                                $_470 = true;
3848
                                break;
3849
                            }
3850
                            $result = $res_467;
3851
                            $this->pos = $pos_467;
3852
                            $_470 = false;
3853
                            break;
3854
                        } while (0);
3855
                        if ($_470 === true) {
3856
                            $_472 = true;
3857
                            break;
3858
                        }
3859
                        $result = $res_465;
3860
                        $this->pos = $pos_465;
3861
                        $_472 = false;
3862
                        break;
3863
                    } while (0);
3864
                    if ($_472 === false) {
3865
                        $_474 = false;
3866
                        break;
3867
                    }
3868
                    $_474 = true;
3869
                    break;
3870
                } while (0);
3871
                if ($_474 === false) {
3872
                    $result = $res_475;
3873
                    $this->pos = $pos_475;
3874
                    unset($res_475);
3875
                    unset($pos_475);
3876
                    break;
3877
                }
3878
            }
3879
            if (( $subres = $this->literal('<%') ) !== false) {
3880
                $result["text"] .= $subres;
3881
            } else {
3882
                $_492 = false;
3883
                break;
3884
            }
3885
            if (( $subres = $this->whitespace() ) !== false) {
3886
                $result["text"] .= $subres;
3887
            }
3888
            if (( $subres = $this->literal('end_') ) !== false) {
3889
                $result["text"] .= $subres;
3890
            } else {
3891
                $_492 = false;
3892
                break;
3893
            }
3894
            $_488 = null;
3895
            do {
3896
                $_486 = null;
3897
                do {
3898
                    $res_479 = $result;
3899
                    $pos_479 = $this->pos;
3900
                    if (( $subres = $this->literal('cached') ) !== false) {
3901
                        $result["text"] .= $subres;
3902
                        $_486 = true;
3903
                        break;
3904
                    }
3905
                    $result = $res_479;
3906
                    $this->pos = $pos_479;
3907
                    $_484 = null;
3908
                    do {
3909
                        $res_481 = $result;
3910
                        $pos_481 = $this->pos;
3911
                        if (( $subres = $this->literal('uncached') ) !== false) {
3912
                            $result["text"] .= $subres;
3913
                            $_484 = true;
3914
                            break;
3915
                        }
3916
                        $result = $res_481;
3917
                        $this->pos = $pos_481;
3918
                        if (( $subres = $this->literal('cacheblock') ) !== false) {
3919
                            $result["text"] .= $subres;
3920
                            $_484 = true;
3921
                            break;
3922
                        }
3923
                        $result = $res_481;
3924
                        $this->pos = $pos_481;
3925
                        $_484 = false;
3926
                        break;
3927
                    } while (0);
3928
                    if ($_484 === true) {
3929
                        $_486 = true;
3930
                        break;
3931
                    }
3932
                    $result = $res_479;
3933
                    $this->pos = $pos_479;
3934
                    $_486 = false;
3935
                    break;
3936
                } while (0);
3937
                if ($_486 === false) {
3938
                    $_488 = false;
3939
                    break;
3940
                }
3941
                $_488 = true;
3942
                break;
3943
            } while (0);
3944
            if ($_488 === false) {
3945
                $_492 = false;
3946
                break;
3947
            }
3948
            if (( $subres = $this->whitespace() ) !== false) {
3949
                $result["text"] .= $subres;
3950
            }
3951
            if (( $subres = $this->literal('%>') ) !== false) {
3952
                $result["text"] .= $subres;
3953
            } else {
3954
                $_492 = false;
3955
                break;
3956
            }
3957
            $_492 = true;
3958
            break;
3959
        } while (0);
3960
        if ($_492 === true) {
3961
            return $this->finalise($result);
3962
        }
3963
        if ($_492 === false) {
3964
            return false;
3965
        }
3966
    }
3967
3968
3969
3970
    function CacheBlock__construct(&$res)
3971
    {
3972
        $res['subblocks'] = 0;
3973
    }
3974
3975
    function CacheBlock_CacheBlockArguments(&$res, $sub)
3976
    {
3977
        $res['key'] = !empty($sub['php']) ? $sub['php'] : '';
3978
    }
3979
3980
    function CacheBlock_Condition(&$res, $sub)
3981
    {
3982
        $res['condition'] = ($res['Conditional']['text'] == 'if' ? '(' : '!(') . $sub['php'] . ') && ';
3983
    }
3984
3985
    function CacheBlock_CacheBlock(&$res, $sub)
3986
    {
3987
        $res['php'] .= $sub['php'];
3988
    }
3989
3990
    function CacheBlock_UncachedBlock(&$res, $sub)
3991
    {
3992
        $res['php'] .= $sub['php'];
3993
    }
3994
3995
    function CacheBlock_CacheBlockTemplate(&$res, $sub)
3996
    {
3997
        // Get the block counter
3998
        $block = ++$res['subblocks'];
3999
        // Build the key for this block from the global key (evaluated in a closure within the template),
4000
        // the passed cache key, the block index, and the sha hash of the template.
4001
        $res['php'] .= '$keyExpression = function() use ($scope, $cache) {' . PHP_EOL;
4002
        $res['php'] .= '$val = \'\';' . PHP_EOL;
4003
        if ($globalKey = SSViewer::config()->get('global_key')) {
4004
            // Embed the code necessary to evaluate the globalKey directly into the template,
4005
            // so that SSTemplateParser only needs to be called during template regeneration.
4006
            // Warning: If the global key is changed, it's necessary to flush the template cache.
4007
            $parser = Injector::inst()->get(__CLASS__, false);
4008
            $result = $parser->compileString($globalKey, '', false, false);
4009
            if (!$result) {
4010
                throw new SSTemplateParseException('Unexpected problem parsing template', $parser);
4011
            }
4012
            $res['php'] .= $result . PHP_EOL;
4013
        }
4014
        $res['php'] .= 'return $val;' . PHP_EOL;
4015
        $res['php'] .= '};' . PHP_EOL;
4016
        $key = 'sha1($keyExpression())' // Global key
4017
            . '.\'_' . sha1($sub['php']) // sha of template
4018
            . (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") // Passed key
4019
            . ".'_$block'"; // block index
4020
        // Get any condition
4021
        $condition = isset($res['condition']) ? $res['condition'] : '';
4022
4023
        $res['php'] .= 'if ('.$condition.'($partial = $cache->load('.$key.'))) $val .= $partial;' . PHP_EOL;
4024
        $res['php'] .= 'else { $oldval = $val; $val = "";' . PHP_EOL;
4025
        $res['php'] .= $sub['php'] . PHP_EOL;
4026
        $res['php'] .= $condition . ' $cache->save($val); $val = $oldval . $val;' . PHP_EOL;
4027
        $res['php'] .= '}';
4028
    }
4029
4030
    /* OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")? */
4031
    protected $match_OldTPart_typestack = array('OldTPart');
4032
    function match_OldTPart($stack = array())
4033
    {
4034
        $matchrule = "OldTPart";
4035
        $result = $this->construct($matchrule, $matchrule, null);
4036
        $_511 = null;
4037
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4038
            if (( $subres = $this->literal('_t') ) !== false) {
4039
                $result["text"] .= $subres;
4040
            } else {
4041
                $_511 = false;
4042
                break;
4043
            }
4044
            $matcher = 'match_'.'N';
4045
            $key = $matcher;
4046
            $pos = $this->pos;
4047
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4048
            if ($subres !== false) {
4049
                $this->store($result, $subres);
4050
            } else {
4051
                $_511 = false;
4052
                break;
4053
            }
4054
            if (substr($this->string, $this->pos, 1) == '(') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4055
                $this->pos += 1;
4056
                $result["text"] .= '(';
4057
            } else {
4058
                $_511 = false;
4059
                break;
4060
            }
4061
            $matcher = 'match_'.'N';
4062
            $key = $matcher;
4063
            $pos = $this->pos;
4064
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4065
            if ($subres !== false) {
4066
                $this->store($result, $subres);
4067
            } else {
4068
                $_511 = false;
4069
                break;
4070
            }
4071
            $matcher = 'match_'.'QuotedString';
4072
            $key = $matcher;
4073
            $pos = $this->pos;
4074
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4075
            if ($subres !== false) {
4076
                $this->store($result, $subres);
4077
            } else {
4078
                $_511 = false;
4079
                break;
4080
            }
4081
            $res_504 = $result;
4082
            $pos_504 = $this->pos;
4083
            $_503 = null;
4084
            do {
4085
                $matcher = 'match_'.'N';
4086
                $key = $matcher;
4087
                $pos = $this->pos;
4088
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4089
                if ($subres !== false) {
4090
                    $this->store($result, $subres);
4091
                } else {
4092
                    $_503 = false;
4093
                    break;
4094
                }
4095
                if (substr($this->string, $this->pos, 1) == ',') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4096
                    $this->pos += 1;
4097
                    $result["text"] .= ',';
4098
                } else {
4099
                    $_503 = false;
4100
                    break;
4101
                }
4102
                $matcher = 'match_'.'N';
4103
                $key = $matcher;
4104
                $pos = $this->pos;
4105
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4106
                if ($subres !== false) {
4107
                    $this->store($result, $subres);
4108
                } else {
4109
                    $_503 = false;
4110
                    break;
4111
                }
4112
                $matcher = 'match_'.'CallArguments';
4113
                $key = $matcher;
4114
                $pos = $this->pos;
4115
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4116
                if ($subres !== false) {
4117
                    $this->store($result, $subres);
4118
                } else {
4119
                    $_503 = false;
4120
                    break;
4121
                }
4122
                $_503 = true;
4123
                break;
4124
            } while (0);
4125
            if ($_503 === false) {
4126
                $result = $res_504;
4127
                $this->pos = $pos_504;
4128
                unset($res_504);
4129
                unset($pos_504);
4130
            }
4131
            $matcher = 'match_'.'N';
4132
            $key = $matcher;
4133
            $pos = $this->pos;
4134
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4135
            if ($subres !== false) {
4136
                $this->store($result, $subres);
4137
            } else {
4138
                $_511 = false;
4139
                break;
4140
            }
4141
            if (substr($this->string, $this->pos, 1) == ')') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4142
                $this->pos += 1;
4143
                $result["text"] .= ')';
4144
            } else {
4145
                $_511 = false;
4146
                break;
4147
            }
4148
            $matcher = 'match_'.'N';
4149
            $key = $matcher;
4150
            $pos = $this->pos;
4151
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4152
            if ($subres !== false) {
4153
                $this->store($result, $subres);
4154
            } else {
4155
                $_511 = false;
4156
                break;
4157
            }
4158
            $res_510 = $result;
4159
            $pos_510 = $this->pos;
4160
            $_509 = null;
4161
            do {
4162
                if (substr($this->string, $this->pos, 1) == ';') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4163
                    $this->pos += 1;
4164
                    $result["text"] .= ';';
4165
                } else {
4166
                    $_509 = false;
4167
                    break;
4168
                }
4169
                $_509 = true;
4170
                break;
4171
            } while (0);
4172
            if ($_509 === false) {
4173
                $result = $res_510;
4174
                $this->pos = $pos_510;
4175
                unset($res_510);
4176
                unset($pos_510);
4177
            }
4178
            $_511 = true;
4179
            break;
4180
        } while (0);
4181
        if ($_511 === true) {
4182
            return $this->finalise($result);
4183
        }
4184
        if ($_511 === false) {
4185
            return false;
4186
        }
4187
    }
4188
4189
4190
    /* N: / [\s\n]* / */
4191
    protected $match_N_typestack = array('N');
4192
    function match_N($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
4193
    {
4194
        $matchrule = "N";
4195
        $result = $this->construct($matchrule, $matchrule, null);
4196
        if (( $subres = $this->rx('/ [\s\n]* /') ) !== false) {
4197
            $result["text"] .= $subres;
4198
            return $this->finalise($result);
4199
        } else {
4200
            return false;
4201
        }
4202
    }
4203
4204
4205
4206
    function OldTPart__construct(&$res)
4207
    {
4208
        $res['php'] = "_t(";
4209
    }
4210
4211
    function OldTPart_QuotedString(&$res, $sub)
4212
    {
4213
        $entity = $sub['String']['text'];
4214
        if (strpos($entity, '.') === false) {
4215
            $res['php'] .= "\$scope->XML_val('I18NNamespace').'.$entity'";
4216
        } else {
4217
            $res['php'] .= "'$entity'";
4218
        }
4219
    }
4220
4221
    function OldTPart_CallArguments(&$res, $sub)
4222
    {
4223
        $res['php'] .= ',' . $sub['php'];
4224
    }
4225
4226
    function OldTPart__finalise(&$res)
4227
    {
4228
        $res['php'] .= ')';
4229
    }
4230
4231
    /* OldTTag: "<%" < OldTPart > "%>" */
4232
    protected $match_OldTTag_typestack = array('OldTTag');
4233
    function match_OldTTag($stack = array())
4234
    {
4235
        $matchrule = "OldTTag";
4236
        $result = $this->construct($matchrule, $matchrule, null);
4237
        $_519 = null;
4238
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4239
            if (( $subres = $this->literal('<%') ) !== false) {
4240
                $result["text"] .= $subres;
4241
            } else {
4242
                $_519 = false;
4243
                break;
4244
            }
4245
            if (( $subres = $this->whitespace() ) !== false) {
4246
                $result["text"] .= $subres;
4247
            }
4248
            $matcher = 'match_'.'OldTPart';
4249
            $key = $matcher;
4250
            $pos = $this->pos;
4251
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4252
            if ($subres !== false) {
4253
                $this->store($result, $subres);
4254
            } else {
4255
                $_519 = false;
4256
                break;
4257
            }
4258
            if (( $subres = $this->whitespace() ) !== false) {
4259
                $result["text"] .= $subres;
4260
            }
4261
            if (( $subres = $this->literal('%>') ) !== false) {
4262
                $result["text"] .= $subres;
4263
            } else {
4264
                $_519 = false;
4265
                break;
4266
            }
4267
            $_519 = true;
4268
            break;
4269
        } while (0);
4270
        if ($_519 === true) {
4271
            return $this->finalise($result);
4272
        }
4273
        if ($_519 === false) {
4274
            return false;
4275
        }
4276
    }
4277
4278
4279
4280
    function OldTTag_OldTPart(&$res, $sub)
4281
    {
4282
        $res['php'] = $sub['php'];
4283
    }
4284
4285
    /* OldSprintfTag: "<%" < "sprintf" < "(" < OldTPart < "," < CallArguments > ")" > "%>" */
4286
    protected $match_OldSprintfTag_typestack = array('OldSprintfTag');
4287
    function match_OldSprintfTag($stack = array())
4288
    {
4289
        $matchrule = "OldSprintfTag";
4290
        $result = $this->construct($matchrule, $matchrule, null);
4291
        $_536 = null;
4292
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4293
            if (( $subres = $this->literal('<%') ) !== false) {
4294
                $result["text"] .= $subres;
4295
            } else {
4296
                $_536 = false;
4297
                break;
4298
            }
4299
            if (( $subres = $this->whitespace() ) !== false) {
4300
                $result["text"] .= $subres;
4301
            }
4302
            if (( $subres = $this->literal('sprintf') ) !== false) {
4303
                $result["text"] .= $subres;
4304
            } else {
4305
                $_536 = false;
4306
                break;
4307
            }
4308
            if (( $subres = $this->whitespace() ) !== false) {
4309
                $result["text"] .= $subres;
4310
            }
4311
            if (substr($this->string, $this->pos, 1) == '(') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4312
                $this->pos += 1;
4313
                $result["text"] .= '(';
4314
            } else {
4315
                $_536 = false;
4316
                break;
4317
            }
4318
            if (( $subres = $this->whitespace() ) !== false) {
4319
                $result["text"] .= $subres;
4320
            }
4321
            $matcher = 'match_'.'OldTPart';
4322
            $key = $matcher;
4323
            $pos = $this->pos;
4324
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4325
            if ($subres !== false) {
4326
                $this->store($result, $subres);
4327
            } else {
4328
                $_536 = false;
4329
                break;
4330
            }
4331
            if (( $subres = $this->whitespace() ) !== false) {
4332
                $result["text"] .= $subres;
4333
            }
4334
            if (substr($this->string, $this->pos, 1) == ',') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4335
                $this->pos += 1;
4336
                $result["text"] .= ',';
4337
            } else {
4338
                $_536 = false;
4339
                break;
4340
            }
4341
            if (( $subres = $this->whitespace() ) !== false) {
4342
                $result["text"] .= $subres;
4343
            }
4344
            $matcher = 'match_'.'CallArguments';
4345
            $key = $matcher;
4346
            $pos = $this->pos;
4347
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4348
            if ($subres !== false) {
4349
                $this->store($result, $subres);
4350
            } else {
4351
                $_536 = false;
4352
                break;
4353
            }
4354
            if (( $subres = $this->whitespace() ) !== false) {
4355
                $result["text"] .= $subres;
4356
            }
4357
            if (substr($this->string, $this->pos, 1) == ')') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4358
                $this->pos += 1;
4359
                $result["text"] .= ')';
4360
            } else {
4361
                $_536 = false;
4362
                break;
4363
            }
4364
            if (( $subres = $this->whitespace() ) !== false) {
4365
                $result["text"] .= $subres;
4366
            }
4367
            if (( $subres = $this->literal('%>') ) !== false) {
4368
                $result["text"] .= $subres;
4369
            } else {
4370
                $_536 = false;
4371
                break;
4372
            }
4373
            $_536 = true;
4374
            break;
4375
        } while (0);
4376
        if ($_536 === true) {
4377
            return $this->finalise($result);
4378
        }
4379
        if ($_536 === false) {
4380
            return false;
4381
        }
4382
    }
4383
4384
4385
4386
    function OldSprintfTag__construct(&$res)
4387
    {
4388
        $res['php'] = "sprintf(";
4389
    }
4390
4391
    function OldSprintfTag_OldTPart(&$res, $sub)
4392
    {
4393
        $res['php'] .= $sub['php'];
4394
    }
4395
4396
    function OldSprintfTag_CallArguments(&$res, $sub)
4397
    {
4398
        $res['php'] .= ',' . $sub['php'] . ')';
4399
    }
4400
4401
    /* OldI18NTag: OldSprintfTag | OldTTag */
4402
    protected $match_OldI18NTag_typestack = array('OldI18NTag');
4403
    function match_OldI18NTag($stack = array())
4404
    {
4405
        $matchrule = "OldI18NTag";
4406
        $result = $this->construct($matchrule, $matchrule, null);
4407
        $_541 = null;
4408
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_538 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4409
            $res_538 = $result;
4410
            $pos_538 = $this->pos;
4411
            $matcher = 'match_'.'OldSprintfTag';
4412
            $key = $matcher;
4413
            $pos = $this->pos;
4414
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4415
            if ($subres !== false) {
4416
                $this->store($result, $subres);
4417
                $_541 = true;
4418
                break;
4419
            }
4420
            $result = $res_538;
4421
            $this->pos = $pos_538;
4422
            $matcher = 'match_'.'OldTTag';
4423
            $key = $matcher;
4424
            $pos = $this->pos;
4425
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4426
            if ($subres !== false) {
4427
                $this->store($result, $subres);
4428
                $_541 = true;
4429
                break;
4430
            }
4431
            $result = $res_538;
4432
            $this->pos = $pos_538;
4433
            $_541 = false;
4434
            break;
4435
        } while (0);
4436
        if ($_541 === true) {
4437
            return $this->finalise($result);
4438
        }
4439
        if ($_541 === false) {
4440
            return false;
4441
        }
4442
    }
4443
4444
4445
4446
    function OldI18NTag_STR(&$res, $sub)
4447
    {
4448
        $res['php'] = '$val .= ' . $sub['php'] . ';';
4449
    }
4450
4451
    /* NamedArgument: Name:Word "=" Value:Argument */
4452
    protected $match_NamedArgument_typestack = array('NamedArgument');
4453
    function match_NamedArgument($stack = array())
4454
    {
4455
        $matchrule = "NamedArgument";
4456
        $result = $this->construct($matchrule, $matchrule, null);
4457
        $_546 = null;
4458
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4459
            $matcher = 'match_'.'Word';
4460
            $key = $matcher;
4461
            $pos = $this->pos;
4462
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4463
            if ($subres !== false) {
4464
                $this->store($result, $subres, "Name");
4465
            } else {
4466
                $_546 = false;
4467
                break;
4468
            }
4469
            if (substr($this->string, $this->pos, 1) == '=') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4470
                $this->pos += 1;
4471
                $result["text"] .= '=';
4472
            } else {
4473
                $_546 = false;
4474
                break;
4475
            }
4476
            $matcher = 'match_'.'Argument';
4477
            $key = $matcher;
4478
            $pos = $this->pos;
4479
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4480
            if ($subres !== false) {
4481
                $this->store($result, $subres, "Value");
4482
            } else {
4483
                $_546 = false;
4484
                break;
4485
            }
4486
            $_546 = true;
4487
            break;
4488
        } while (0);
4489
        if ($_546 === true) {
4490
            return $this->finalise($result);
4491
        }
4492
        if ($_546 === false) {
4493
            return false;
4494
        }
4495
    }
4496
4497
4498
4499
    function NamedArgument_Name(&$res, $sub)
4500
    {
4501
        $res['php'] = "'" . $sub['text'] . "' => ";
4502
    }
4503
4504
    function NamedArgument_Value(&$res, $sub)
4505
    {
4506
        switch ($sub['ArgumentMode']) {
4507
            case 'string':
4508
                $res['php'] .= $sub['php'];
4509
                break;
4510
4511
            case 'default':
4512
                $res['php'] .= $sub['string_php'];
4513
                break;
4514
4515
            default:
4516
                $res['php'] .= str_replace('$$FINAL', 'obj', $sub['php']) . '->self()';
4517
                break;
4518
        }
4519
    }
4520
4521
    /* Include: "<%" < "include" < Template:NamespacedWord < (NamedArgument ( < "," < NamedArgument )*)? > "%>" */
4522
    protected $match_Include_typestack = array('Include');
4523
    function match_Include($stack = array())
4524
    {
4525
        $matchrule = "Include";
4526
        $result = $this->construct($matchrule, $matchrule, null);
4527
        $_565 = null;
4528
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4529
            if (( $subres = $this->literal('<%') ) !== false) {
4530
                $result["text"] .= $subres;
4531
            } else {
4532
                $_565 = false;
4533
                break;
4534
            }
4535
            if (( $subres = $this->whitespace() ) !== false) {
4536
                $result["text"] .= $subres;
4537
            }
4538
            if (( $subres = $this->literal('include') ) !== false) {
4539
                $result["text"] .= $subres;
4540
            } else {
4541
                $_565 = false;
4542
                break;
4543
            }
4544
            if (( $subres = $this->whitespace() ) !== false) {
4545
                $result["text"] .= $subres;
4546
            }
4547
            $matcher = 'match_'.'NamespacedWord';
4548
            $key = $matcher;
4549
            $pos = $this->pos;
4550
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4551
            if ($subres !== false) {
4552
                $this->store($result, $subres, "Template");
4553
            } else {
4554
                $_565 = false;
4555
                break;
4556
            }
4557
            if (( $subres = $this->whitespace() ) !== false) {
4558
                $result["text"] .= $subres;
4559
            }
4560
            $res_562 = $result;
4561
            $pos_562 = $this->pos;
4562
            $_561 = null;
4563
            do {
4564
                $matcher = 'match_'.'NamedArgument';
4565
                $key = $matcher;
4566
                $pos = $this->pos;
4567
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4568
                if ($subres !== false) {
4569
                    $this->store($result, $subres);
4570
                } else {
4571
                    $_561 = false;
4572
                    break;
4573
                }
4574
                while (true) {
4575
                    $res_560 = $result;
4576
                    $pos_560 = $this->pos;
4577
                    $_559 = null;
4578
                    do {
4579
                        if (( $subres = $this->whitespace() ) !== false) {
4580
                            $result["text"] .= $subres;
4581
                        }
4582
                        if (substr($this->string, $this->pos, 1) == ',') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4583
                            $this->pos += 1;
4584
                            $result["text"] .= ',';
4585
                        } else {
4586
                            $_559 = false;
4587
                            break;
4588
                        }
4589
                        if (( $subres = $this->whitespace() ) !== false) {
4590
                            $result["text"] .= $subres;
4591
                        }
4592
                        $matcher = 'match_'.'NamedArgument';
4593
                        $key = $matcher;
4594
                        $pos = $this->pos;
4595
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4596
                        if ($subres !== false) {
4597
                            $this->store($result, $subres);
4598
                        } else {
4599
                            $_559 = false;
4600
                            break;
4601
                        }
4602
                        $_559 = true;
4603
                        break;
4604
                    } while (0);
4605
                    if ($_559 === false) {
4606
                        $result = $res_560;
4607
                        $this->pos = $pos_560;
4608
                        unset($res_560);
4609
                        unset($pos_560);
4610
                        break;
4611
                    }
4612
                }
4613
                $_561 = true;
4614
                break;
4615
            } while (0);
4616
            if ($_561 === false) {
4617
                $result = $res_562;
4618
                $this->pos = $pos_562;
4619
                unset($res_562);
4620
                unset($pos_562);
4621
            }
4622
            if (( $subres = $this->whitespace() ) !== false) {
4623
                $result["text"] .= $subres;
4624
            }
4625
            if (( $subres = $this->literal('%>') ) !== false) {
4626
                $result["text"] .= $subres;
4627
            } else {
4628
                $_565 = false;
4629
                break;
4630
            }
4631
            $_565 = true;
4632
            break;
4633
        } while (0);
4634
        if ($_565 === true) {
4635
            return $this->finalise($result);
4636
        }
4637
        if ($_565 === false) {
4638
            return false;
4639
        }
4640
    }
4641
4642
4643
4644
    function Include__construct(&$res)
4645
    {
4646
        $res['arguments'] = array();
4647
    }
4648
4649
    function Include_Template(&$res, $sub)
4650
    {
4651
        $res['template'] = "'" . $sub['text'] . "'";
4652
    }
4653
4654
    function Include_NamedArgument(&$res, $sub)
4655
    {
4656
        $res['arguments'][] = $sub['php'];
4657
    }
4658
4659
    function Include__finalise(&$res)
4660
    {
4661
        $template = $res['template'];
4662
        $arguments = $res['arguments'];
4663
4664
        $res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template(["type" => "Includes", '.$template.'], $scope->getItem(), array(' .
4665
            implode(',', $arguments)."), \$scope);\n";
4666
4667
        if ($this->includeDebuggingComments) { // Add include filename comments on dev sites
4668
            $res['php'] =
4669
                '$val .= \'<!-- include '.addslashes($template).' -->\';'. "\n".
4670
                $res['php'].
4671
                '$val .= \'<!-- end include '.addslashes($template).' -->\';'. "\n";
4672
        }
4673
    }
4674
4675
    /* BlockArguments: :Argument ( < "," < :Argument)* */
4676
    protected $match_BlockArguments_typestack = array('BlockArguments');
4677
    function match_BlockArguments($stack = array())
4678
    {
4679
        $matchrule = "BlockArguments";
4680
        $result = $this->construct($matchrule, $matchrule, null);
4681
        $_574 = null;
4682
        do {
0 ignored issues
show
Unused Code introduced by
do { $matcher = 'mat... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4683
            $matcher = 'match_'.'Argument';
4684
            $key = $matcher;
4685
            $pos = $this->pos;
4686
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4687
            if ($subres !== false) {
4688
                $this->store($result, $subres, "Argument");
4689
            } else {
4690
                $_574 = false;
4691
                break;
4692
            }
4693
            while (true) {
4694
                $res_573 = $result;
4695
                $pos_573 = $this->pos;
4696
                $_572 = null;
4697
                do {
4698
                    if (( $subres = $this->whitespace() ) !== false) {
4699
                        $result["text"] .= $subres;
4700
                    }
4701
                    if (substr($this->string, $this->pos, 1) == ',') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
4702
                        $this->pos += 1;
4703
                        $result["text"] .= ',';
4704
                    } else {
4705
                        $_572 = false;
4706
                        break;
4707
                    }
4708
                    if (( $subres = $this->whitespace() ) !== false) {
4709
                        $result["text"] .= $subres;
4710
                    }
4711
                    $matcher = 'match_'.'Argument';
4712
                    $key = $matcher;
4713
                    $pos = $this->pos;
4714
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4715
                    if ($subres !== false) {
4716
                        $this->store($result, $subres, "Argument");
4717
                    } else {
4718
                        $_572 = false;
4719
                        break;
4720
                    }
4721
                    $_572 = true;
4722
                    break;
4723
                } while (0);
4724
                if ($_572 === false) {
4725
                    $result = $res_573;
4726
                    $this->pos = $pos_573;
4727
                    unset($res_573);
4728
                    unset($pos_573);
4729
                    break;
4730
                }
4731
            }
4732
            $_574 = true;
4733
            break;
4734
        } while (0);
4735
        if ($_574 === true) {
4736
            return $this->finalise($result);
4737
        }
4738
        if ($_574 === false) {
4739
            return false;
4740
        }
4741
    }
4742
4743
4744
    /* NotBlockTag: "end_" | (("if" | "else_if" | "else" | "require" | "cached" | "uncached" | "cacheblock" | "include")]) */
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
4745
    protected $match_NotBlockTag_typestack = array('NotBlockTag');
4746
    function match_NotBlockTag($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
4747
    {
4748
        $matchrule = "NotBlockTag";
4749
        $result = $this->construct($matchrule, $matchrule, null);
4750
        $_612 = null;
4751
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_576 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4752
            $res_576 = $result;
4753
            $pos_576 = $this->pos;
4754
            if (( $subres = $this->literal('end_') ) !== false) {
4755
                $result["text"] .= $subres;
4756
                $_612 = true;
4757
                break;
4758
            }
4759
            $result = $res_576;
4760
            $this->pos = $pos_576;
4761
            $_610 = null;
4762
            do {
4763
                $_607 = null;
4764
                do {
4765
                    $_605 = null;
4766
                    do {
4767
                        $res_578 = $result;
4768
                        $pos_578 = $this->pos;
4769
                        if (( $subres = $this->literal('if') ) !== false) {
4770
                            $result["text"] .= $subres;
4771
                            $_605 = true;
4772
                            break;
4773
                        }
4774
                        $result = $res_578;
4775
                        $this->pos = $pos_578;
4776
                        $_603 = null;
4777
                        do {
4778
                            $res_580 = $result;
4779
                            $pos_580 = $this->pos;
4780
                            if (( $subres = $this->literal('else_if') ) !== false) {
4781
                                $result["text"] .= $subres;
4782
                                $_603 = true;
4783
                                break;
4784
                            }
4785
                            $result = $res_580;
4786
                            $this->pos = $pos_580;
4787
                            $_601 = null;
4788
                            do {
4789
                                $res_582 = $result;
4790
                                $pos_582 = $this->pos;
4791
                                if (( $subres = $this->literal('else') ) !== false) {
4792
                                    $result["text"] .= $subres;
4793
                                    $_601 = true;
4794
                                    break;
4795
                                }
4796
                                $result = $res_582;
4797
                                $this->pos = $pos_582;
4798
                                $_599 = null;
4799
                                do {
4800
                                    $res_584 = $result;
4801
                                    $pos_584 = $this->pos;
4802
                                    if (( $subres = $this->literal('require') ) !== false) {
4803
                                        $result["text"] .= $subres;
4804
                                        $_599 = true;
4805
                                        break;
4806
                                    }
4807
                                    $result = $res_584;
4808
                                    $this->pos = $pos_584;
4809
                                    $_597 = null;
4810
                                    do {
4811
                                        $res_586 = $result;
4812
                                        $pos_586 = $this->pos;
4813
                                        if (( $subres = $this->literal('cached') ) !== false) {
4814
                                            $result["text"] .= $subres;
4815
                                            $_597 = true;
4816
                                            break;
4817
                                        }
4818
                                        $result = $res_586;
4819
                                        $this->pos = $pos_586;
4820
                                        $_595 = null;
4821
                                        do {
4822
                                            $res_588 = $result;
4823
                                            $pos_588 = $this->pos;
4824
                                            if (( $subres = $this->literal('uncached') ) !== false) {
4825
                                                $result["text"] .= $subres;
4826
                                                $_595 = true;
4827
                                                break;
4828
                                            }
4829
                                            $result = $res_588;
4830
                                            $this->pos = $pos_588;
4831
                                            $_593 = null;
4832
                                            do {
4833
                                                $res_590 = $result;
4834
                                                $pos_590 = $this->pos;
4835
                                                if (( $subres = $this->literal('cacheblock') ) !== false) {
4836
                                                    $result["text"] .= $subres;
4837
                                                    $_593 = true;
4838
                                                    break;
4839
                                                }
4840
                                                $result = $res_590;
4841
                                                $this->pos = $pos_590;
4842
                                                if (( $subres = $this->literal('include') ) !== false) {
4843
                                                    $result["text"] .= $subres;
4844
                                                    $_593 = true;
4845
                                                    break;
4846
                                                }
4847
                                                $result = $res_590;
4848
                                                $this->pos = $pos_590;
4849
                                                $_593 = false;
4850
                                                break;
4851
                                            } while (0);
4852
                                            if ($_593 === true) {
4853
                                                $_595 = true;
4854
                                                break;
4855
                                            }
4856
                                            $result = $res_588;
4857
                                            $this->pos = $pos_588;
4858
                                            $_595 = false;
4859
                                            break;
4860
                                        } while (0);
4861
                                        if ($_595 === true) {
4862
                                            $_597 = true;
4863
                                            break;
4864
                                        }
4865
                                        $result = $res_586;
4866
                                        $this->pos = $pos_586;
4867
                                        $_597 = false;
4868
                                        break;
4869
                                    } while (0);
4870
                                    if ($_597 === true) {
4871
                                        $_599 = true;
4872
                                        break;
4873
                                    }
4874
                                    $result = $res_584;
4875
                                    $this->pos = $pos_584;
4876
                                    $_599 = false;
4877
                                    break;
4878
                                } while (0);
4879
                                if ($_599 === true) {
4880
                                    $_601 = true;
4881
                                    break;
4882
                                }
4883
                                $result = $res_582;
4884
                                $this->pos = $pos_582;
4885
                                $_601 = false;
4886
                                break;
4887
                            } while (0);
4888
                            if ($_601 === true) {
4889
                                $_603 = true;
4890
                                break;
4891
                            }
4892
                            $result = $res_580;
4893
                            $this->pos = $pos_580;
4894
                            $_603 = false;
4895
                            break;
4896
                        } while (0);
4897
                        if ($_603 === true) {
4898
                            $_605 = true;
4899
                            break;
4900
                        }
4901
                        $result = $res_578;
4902
                        $this->pos = $pos_578;
4903
                        $_605 = false;
4904
                        break;
4905
                    } while (0);
4906
                    if ($_605 === false) {
4907
                        $_607 = false;
4908
                        break;
4909
                    }
4910
                    $_607 = true;
4911
                    break;
4912
                } while (0);
4913
                if ($_607 === false) {
4914
                    $_610 = false;
4915
                    break;
4916
                }
4917
                if (( $subres = $this->whitespace() ) !== false) {
4918
                    $result["text"] .= $subres;
4919
                } else {
4920
                    $_610 = false;
4921
                    break;
4922
                }
4923
                $_610 = true;
4924
                break;
4925
            } while (0);
4926
            if ($_610 === true) {
4927
                $_612 = true;
4928
                break;
4929
            }
4930
            $result = $res_576;
4931
            $this->pos = $pos_576;
4932
            $_612 = false;
4933
            break;
4934
        } while (0);
4935
        if ($_612 === true) {
4936
            return $this->finalise($result);
4937
        }
4938
        if ($_612 === false) {
4939
            return false;
4940
        }
4941
    }
4942
4943
4944
    /* ClosedBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > Zap:'%>' Template:$TemplateMatcher?
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
4945
	'<%' < 'end_' '$BlockName' > '%>' */
4946
    protected $match_ClosedBlock_typestack = array('ClosedBlock');
4947
    function match_ClosedBlock($stack = array())
4948
    {
4949
        $matchrule = "ClosedBlock";
4950
        $result = $this->construct($matchrule, $matchrule, null);
4951
        $_632 = null;
4952
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
4953
            if (( $subres = $this->literal('<%') ) !== false) {
4954
                $result["text"] .= $subres;
4955
            } else {
4956
                $_632 = false;
4957
                break;
4958
            }
4959
            if (( $subres = $this->whitespace() ) !== false) {
4960
                $result["text"] .= $subres;
4961
            }
4962
            $res_616 = $result;
4963
            $pos_616 = $this->pos;
4964
            $matcher = 'match_'.'NotBlockTag';
4965
            $key = $matcher;
4966
            $pos = $this->pos;
4967
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4968
            if ($subres !== false) {
4969
                $this->store($result, $subres);
4970
                $result = $res_616;
4971
                $this->pos = $pos_616;
4972
                $_632 = false;
4973
                break;
4974
            } else {
4975
                $result = $res_616;
4976
                $this->pos = $pos_616;
4977
            }
4978
            $matcher = 'match_'.'Word';
4979
            $key = $matcher;
4980
            $pos = $this->pos;
4981
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
4982
            if ($subres !== false) {
4983
                $this->store($result, $subres, "BlockName");
4984
            } else {
4985
                $_632 = false;
4986
                break;
4987
            }
4988
            $res_622 = $result;
4989
            $pos_622 = $this->pos;
4990
            $_621 = null;
4991
            do {
4992
                if (( $subres = $this->whitespace() ) !== false) {
4993
                    $result["text"] .= $subres;
4994
                } else {
4995
                    $_621 = false;
4996
                    break;
4997
                }
4998
                $matcher = 'match_'.'BlockArguments';
4999
                $key = $matcher;
5000
                $pos = $this->pos;
5001
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5002
                if ($subres !== false) {
5003
                    $this->store($result, $subres, "BlockArguments");
5004
                } else {
5005
                    $_621 = false;
5006
                    break;
5007
                }
5008
                if (( $subres = $this->whitespace() ) !== false) {
5009
                    $result["text"] .= $subres;
5010
                } else {
5011
                    $_621 = false;
5012
                    break;
5013
                }
5014
                $_621 = true;
5015
                break;
5016
            } while (0);
5017
            if ($_621 === false) {
5018
                $result = $res_622;
5019
                $this->pos = $pos_622;
5020
                unset($res_622);
5021
                unset($pos_622);
5022
            }
5023
            if (( $subres = $this->whitespace() ) !== false) {
5024
                $result["text"] .= $subres;
5025
            }
5026
            $stack[] = $result;
5027
            $result = $this->construct($matchrule, "Zap");
5028
            if (( $subres = $this->literal('%>') ) !== false) {
5029
                $result["text"] .= $subres;
5030
                $subres = $result;
5031
                $result = array_pop($stack);
5032
                $this->store($result, $subres, 'Zap');
5033
            } else {
5034
                $result = array_pop($stack);
5035
                $_632 = false;
5036
                break;
5037
            }
5038
            $res_625 = $result;
5039
            $pos_625 = $this->pos;
5040
            $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher');
5041
            $key = $matcher;
5042
            $pos = $this->pos;
5043
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5044
            if ($subres !== false) {
5045
                $this->store($result, $subres, "Template");
5046
            } else {
5047
                $result = $res_625;
5048
                $this->pos = $pos_625;
5049
                unset($res_625);
5050
                unset($pos_625);
5051
            }
5052
            if (( $subres = $this->literal('<%') ) !== false) {
5053
                $result["text"] .= $subres;
5054
            } else {
5055
                $_632 = false;
5056
                break;
5057
            }
5058
            if (( $subres = $this->whitespace() ) !== false) {
5059
                $result["text"] .= $subres;
5060
            }
5061
            if (( $subres = $this->literal('end_') ) !== false) {
5062
                $result["text"] .= $subres;
5063
            } else {
5064
                $_632 = false;
5065
                break;
5066
            }
5067
            if (( $subres = $this->literal(''.$this->expression($result, $stack, 'BlockName').'') ) !== false) {
5068
                $result["text"] .= $subres;
5069
            } else {
5070
                $_632 = false;
5071
                break;
5072
            }
5073
            if (( $subres = $this->whitespace() ) !== false) {
5074
                $result["text"] .= $subres;
5075
            }
5076
            if (( $subres = $this->literal('%>') ) !== false) {
5077
                $result["text"] .= $subres;
5078
            } else {
5079
                $_632 = false;
5080
                break;
5081
            }
5082
            $_632 = true;
5083
            break;
5084
        } while (0);
5085
        if ($_632 === true) {
5086
            return $this->finalise($result);
5087
        }
5088
        if ($_632 === false) {
5089
            return false;
5090
        }
5091
    }
5092
5093
5094
5095
5096
    /**
5097
     * As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule
5098
     * builds up two important elements in the match result array:
5099
     *   'ArgumentCount' - how many arguments were passed in the opening tag
5100
     *   'Arguments' an array of the Argument match rule result arrays
5101
     *
5102
     * Once a block has successfully been matched against, it will then look for the actual handler, which should
5103
     * be on this class (either defined or extended on) as ClosedBlock_Handler_Name(&$res), where Name is the
5104
     * tag name, first letter captialized (i.e Control, Loop, With, etc).
5105
     *
5106
     * This function will be called with the match rule result array as it's first argument. It should return
5107
     * the php result of this block as it's return value, or throw an error if incorrect arguments were passed.
5108
     */
5109
5110
    function ClosedBlock__construct(&$res)
5111
    {
5112
        $res['ArgumentCount'] = 0;
5113
    }
5114
5115
    function ClosedBlock_BlockArguments(&$res, $sub)
5116
    {
5117
        if (isset($sub['Argument']['ArgumentMode'])) {
5118
            $res['Arguments'] = array($sub['Argument']);
5119
            $res['ArgumentCount'] = 1;
5120
        } else {
5121
            $res['Arguments'] = $sub['Argument'];
5122
            $res['ArgumentCount'] = count($res['Arguments']);
5123
        }
5124
    }
5125
5126
    function ClosedBlock__finalise(&$res)
5127
    {
5128
        $blockname = $res['BlockName']['text'];
5129
5130
        $method = 'ClosedBlock_Handle_'.$blockname;
5131
        if (method_exists($this, $method)) {
5132
            $res['php'] = $this->$method($res);
5133
        } elseif (isset($this->closedBlocks[$blockname])) {
5134
            $res['php'] = call_user_func($this->closedBlocks[$blockname], $res);
5135
        } else {
5136
            throw new SSTemplateParseException('Unknown closed block "'.$blockname.'" encountered. Perhaps you are ' .
5137
            'not supposed to close this block, or have mis-spelled it?', $this);
5138
        }
5139
    }
5140
5141
    /**
5142
     * This is an example of a block handler function. This one handles the loop tag.
5143
     */
5144
    function ClosedBlock_Handle_Loop(&$res)
5145
    {
5146
        if ($res['ArgumentCount'] > 1) {
5147
            throw new SSTemplateParseException('Either no or too many arguments in control block. Must be one ' .
5148
                'argument only.', $this);
5149
        }
5150
5151
        //loop without arguments loops on the current scope
5152
        if ($res['ArgumentCount'] == 0) {
5153
            $on = '$scope->obj(\'Up\', null)->obj(\'Foo\', null)';
5154
        } else {    //loop in the normal way
5155
            $arg = $res['Arguments'][0];
5156
            if ($arg['ArgumentMode'] == 'string') {
5157
                throw new SSTemplateParseException('Control block cant take string as argument.', $this);
5158
            }
5159
            $on = str_replace(
5160
                '$$FINAL',
5161
                'obj',
5162
                ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']
5163
            );
5164
        }
5165
5166
        return
5167
            $on . '; $scope->pushScope(); while (($key = $scope->next()) !== false) {' . PHP_EOL .
5168
                $res['Template']['php'] . PHP_EOL .
5169
            '}; $scope->popScope(); ';
5170
    }
5171
5172
    /**
5173
     * The closed block handler for with blocks
5174
     */
5175
    function ClosedBlock_Handle_With(&$res)
5176
    {
5177
        if ($res['ArgumentCount'] != 1) {
5178
            throw new SSTemplateParseException('Either no or too many arguments in with block. Must be one ' .
5179
                'argument only.', $this);
5180
        }
5181
5182
        $arg = $res['Arguments'][0];
5183
        if ($arg['ArgumentMode'] == 'string') {
5184
            throw new SSTemplateParseException('Control block cant take string as argument.', $this);
5185
        }
5186
5187
        $on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
5188
        return
5189
            $on . '; $scope->pushScope();' . PHP_EOL .
5190
                $res['Template']['php'] . PHP_EOL .
5191
            '; $scope->popScope(); ';
5192
    }
5193
5194
    /* OpenBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > '%>' */
5195
    protected $match_OpenBlock_typestack = array('OpenBlock');
5196
    function match_OpenBlock($stack = array())
5197
    {
5198
        $matchrule = "OpenBlock";
5199
        $result = $this->construct($matchrule, $matchrule, null);
5200
        $_645 = null;
5201
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
5202
            if (( $subres = $this->literal('<%') ) !== false) {
5203
                $result["text"] .= $subres;
5204
            } else {
5205
                $_645 = false;
5206
                break;
5207
            }
5208
            if (( $subres = $this->whitespace() ) !== false) {
5209
                $result["text"] .= $subres;
5210
            }
5211
            $res_636 = $result;
5212
            $pos_636 = $this->pos;
5213
            $matcher = 'match_'.'NotBlockTag';
5214
            $key = $matcher;
5215
            $pos = $this->pos;
5216
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5217
            if ($subres !== false) {
5218
                $this->store($result, $subres);
5219
                $result = $res_636;
5220
                $this->pos = $pos_636;
5221
                $_645 = false;
5222
                break;
5223
            } else {
5224
                $result = $res_636;
5225
                $this->pos = $pos_636;
5226
            }
5227
            $matcher = 'match_'.'Word';
5228
            $key = $matcher;
5229
            $pos = $this->pos;
5230
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5231
            if ($subres !== false) {
5232
                $this->store($result, $subres, "BlockName");
5233
            } else {
5234
                $_645 = false;
5235
                break;
5236
            }
5237
            $res_642 = $result;
5238
            $pos_642 = $this->pos;
5239
            $_641 = null;
5240
            do {
5241
                if (( $subres = $this->whitespace() ) !== false) {
5242
                    $result["text"] .= $subres;
5243
                } else {
5244
                    $_641 = false;
5245
                    break;
5246
                }
5247
                $matcher = 'match_'.'BlockArguments';
5248
                $key = $matcher;
5249
                $pos = $this->pos;
5250
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5251
                if ($subres !== false) {
5252
                    $this->store($result, $subres, "BlockArguments");
5253
                } else {
5254
                    $_641 = false;
5255
                    break;
5256
                }
5257
                if (( $subres = $this->whitespace() ) !== false) {
5258
                    $result["text"] .= $subres;
5259
                } else {
5260
                    $_641 = false;
5261
                    break;
5262
                }
5263
                $_641 = true;
5264
                break;
5265
            } while (0);
5266
            if ($_641 === false) {
5267
                $result = $res_642;
5268
                $this->pos = $pos_642;
5269
                unset($res_642);
5270
                unset($pos_642);
5271
            }
5272
            if (( $subres = $this->whitespace() ) !== false) {
5273
                $result["text"] .= $subres;
5274
            }
5275
            if (( $subres = $this->literal('%>') ) !== false) {
5276
                $result["text"] .= $subres;
5277
            } else {
5278
                $_645 = false;
5279
                break;
5280
            }
5281
            $_645 = true;
5282
            break;
5283
        } while (0);
5284
        if ($_645 === true) {
5285
            return $this->finalise($result);
5286
        }
5287
        if ($_645 === false) {
5288
            return false;
5289
        }
5290
    }
5291
5292
5293
5294
    function OpenBlock__construct(&$res)
5295
    {
5296
        $res['ArgumentCount'] = 0;
5297
    }
5298
5299
    function OpenBlock_BlockArguments(&$res, $sub)
5300
    {
5301
        if (isset($sub['Argument']['ArgumentMode'])) {
5302
            $res['Arguments'] = array($sub['Argument']);
5303
            $res['ArgumentCount'] = 1;
5304
        } else {
5305
            $res['Arguments'] = $sub['Argument'];
5306
            $res['ArgumentCount'] = count($res['Arguments']);
5307
        }
5308
    }
5309
5310
    function OpenBlock__finalise(&$res)
5311
    {
5312
        $blockname = $res['BlockName']['text'];
5313
5314
        $method = 'OpenBlock_Handle_'.$blockname;
5315
        if (method_exists($this, $method)) {
5316
            $res['php'] = $this->$method($res);
5317
        } elseif (isset($this->openBlocks[$blockname])) {
5318
            $res['php'] = call_user_func($this->openBlocks[$blockname], $res);
5319
        } else {
5320
            throw new SSTemplateParseException('Unknown open block "'.$blockname.'" encountered. Perhaps you missed ' .
5321
            ' the closing tag or have mis-spelled it?', $this);
5322
        }
5323
    }
5324
5325
    /**
5326
     * This is an open block handler, for the <% debug %> utility tag
5327
     */
5328
    function OpenBlock_Handle_Debug(&$res)
5329
    {
5330
        if ($res['ArgumentCount'] == 0) {
5331
            return '$scope->debug();';
5332
        } elseif ($res['ArgumentCount'] == 1) {
5333
            $arg = $res['Arguments'][0];
5334
5335
            if ($arg['ArgumentMode'] == 'string') {
5336
                return 'Debug::show('.$arg['php'].');';
5337
            }
5338
5339
            $php = ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php'];
5340
            return '$val .= Debug::show('.str_replace('FINALGET!', 'cachedCall', $php).');';
5341
        } else {
5342
            throw new SSTemplateParseException('Debug takes 0 or 1 argument only.', $this);
5343
        }
5344
    }
5345
5346
    /**
5347
     * This is an open block handler, for the <% base_tag %> tag
5348
     */
5349
    function OpenBlock_Handle_Base_tag(&$res)
5350
    {
5351
        if ($res['ArgumentCount'] != 0) {
5352
            throw new SSTemplateParseException('Base_tag takes no arguments', $this);
5353
        }
5354
        return '$val .= \\SilverStripe\\View\\SSViewer::get_base_tag($val);';
5355
    }
5356
5357
    /**
5358
     * This is an open block handler, for the <% current_page %> tag
5359
     */
5360
    function OpenBlock_Handle_Current_page(&$res)
5361
    {
5362
        if ($res['ArgumentCount'] != 0) {
5363
            throw new SSTemplateParseException('Current_page takes no arguments', $this);
5364
        }
5365
        return '$val .= $_SERVER[SCRIPT_URL];';
5366
    }
5367
5368
    /* MismatchedEndBlock: '<%' < 'end_' :Word > '%>' */
5369
    protected $match_MismatchedEndBlock_typestack = array('MismatchedEndBlock');
5370
    function match_MismatchedEndBlock($stack = array())
5371
    {
5372
        $matchrule = "MismatchedEndBlock";
5373
        $result = $this->construct($matchrule, $matchrule, null);
5374
        $_653 = null;
5375
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
5376
            if (( $subres = $this->literal('<%') ) !== false) {
5377
                $result["text"] .= $subres;
5378
            } else {
5379
                $_653 = false;
5380
                break;
5381
            }
5382
            if (( $subres = $this->whitespace() ) !== false) {
5383
                $result["text"] .= $subres;
5384
            }
5385
            if (( $subres = $this->literal('end_') ) !== false) {
5386
                $result["text"] .= $subres;
5387
            } else {
5388
                $_653 = false;
5389
                break;
5390
            }
5391
            $matcher = 'match_'.'Word';
5392
            $key = $matcher;
5393
            $pos = $this->pos;
5394
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5395
            if ($subres !== false) {
5396
                $this->store($result, $subres, "Word");
5397
            } else {
5398
                $_653 = false;
5399
                break;
5400
            }
5401
            if (( $subres = $this->whitespace() ) !== false) {
5402
                $result["text"] .= $subres;
5403
            }
5404
            if (( $subres = $this->literal('%>') ) !== false) {
5405
                $result["text"] .= $subres;
5406
            } else {
5407
                $_653 = false;
5408
                break;
5409
            }
5410
            $_653 = true;
5411
            break;
5412
        } while (0);
5413
        if ($_653 === true) {
5414
            return $this->finalise($result);
5415
        }
5416
        if ($_653 === false) {
5417
            return false;
5418
        }
5419
    }
5420
5421
5422
5423
    function MismatchedEndBlock__finalise(&$res)
5424
    {
5425
        $blockname = $res['Word']['text'];
5426
        throw new SSTemplateParseException('Unexpected close tag end_' . $blockname .
5427
            ' encountered. Perhaps you have mis-nested blocks, or have mis-spelled a tag?', $this);
5428
    }
5429
5430
    /* MalformedOpenTag: '<%' < !NotBlockTag Tag:Word  !( ( [ :BlockArguments ] )? > '%>' ) */
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
5431
    protected $match_MalformedOpenTag_typestack = array('MalformedOpenTag');
5432
    function match_MalformedOpenTag($stack = array())
5433
    {
5434
        $matchrule = "MalformedOpenTag";
5435
        $result = $this->construct($matchrule, $matchrule, null);
5436
        $_668 = null;
5437
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
5438
            if (( $subres = $this->literal('<%') ) !== false) {
5439
                $result["text"] .= $subres;
5440
            } else {
5441
                $_668 = false;
5442
                break;
5443
            }
5444
            if (( $subres = $this->whitespace() ) !== false) {
5445
                $result["text"] .= $subres;
5446
            }
5447
            $res_657 = $result;
5448
            $pos_657 = $this->pos;
5449
            $matcher = 'match_'.'NotBlockTag';
5450
            $key = $matcher;
5451
            $pos = $this->pos;
5452
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5453
            if ($subres !== false) {
5454
                $this->store($result, $subres);
5455
                $result = $res_657;
5456
                $this->pos = $pos_657;
5457
                $_668 = false;
5458
                break;
5459
            } else {
5460
                $result = $res_657;
5461
                $this->pos = $pos_657;
5462
            }
5463
            $matcher = 'match_'.'Word';
5464
            $key = $matcher;
5465
            $pos = $this->pos;
5466
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5467
            if ($subres !== false) {
5468
                $this->store($result, $subres, "Tag");
5469
            } else {
5470
                $_668 = false;
5471
                break;
5472
            }
5473
            $res_667 = $result;
5474
            $pos_667 = $this->pos;
5475
            $_666 = null;
5476
            do {
5477
                $res_663 = $result;
5478
                $pos_663 = $this->pos;
5479
                $_662 = null;
5480
                do {
5481
                    if (( $subres = $this->whitespace() ) !== false) {
5482
                        $result["text"] .= $subres;
5483
                    } else {
5484
                        $_662 = false;
5485
                        break;
5486
                    }
5487
                    $matcher = 'match_'.'BlockArguments';
5488
                    $key = $matcher;
5489
                    $pos = $this->pos;
5490
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5491
                    if ($subres !== false) {
5492
                        $this->store($result, $subres, "BlockArguments");
5493
                    } else {
5494
                        $_662 = false;
5495
                        break;
5496
                    }
5497
                    if (( $subres = $this->whitespace() ) !== false) {
5498
                        $result["text"] .= $subres;
5499
                    } else {
5500
                        $_662 = false;
5501
                        break;
5502
                    }
5503
                    $_662 = true;
5504
                    break;
5505
                } while (0);
5506
                if ($_662 === false) {
5507
                    $result = $res_663;
5508
                    $this->pos = $pos_663;
5509
                    unset($res_663);
5510
                    unset($pos_663);
5511
                }
5512
                if (( $subres = $this->whitespace() ) !== false) {
5513
                    $result["text"] .= $subres;
5514
                }
5515
                if (( $subres = $this->literal('%>') ) !== false) {
5516
                    $result["text"] .= $subres;
5517
                } else {
5518
                    $_666 = false;
5519
                    break;
5520
                }
5521
                $_666 = true;
5522
                break;
5523
            } while (0);
5524
            if ($_666 === true) {
5525
                $result = $res_667;
5526
                $this->pos = $pos_667;
5527
                $_668 = false;
5528
                break;
5529
            }
5530
            if ($_666 === false) {
5531
                $result = $res_667;
5532
                $this->pos = $pos_667;
5533
            }
5534
            $_668 = true;
5535
            break;
5536
        } while (0);
5537
        if ($_668 === true) {
5538
            return $this->finalise($result);
5539
        }
5540
        if ($_668 === false) {
5541
            return false;
5542
        }
5543
    }
5544
5545
5546
5547
    function MalformedOpenTag__finalise(&$res)
5548
    {
5549
        $tag = $res['Tag']['text'];
5550
        throw new SSTemplateParseException("Malformed opening block tag $tag. Perhaps you have tried to use operators?", $this);
5551
    }
5552
5553
    /* MalformedCloseTag: '<%' < Tag:('end_' :Word ) !( > '%>' ) */
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
5554
    protected $match_MalformedCloseTag_typestack = array('MalformedCloseTag');
5555
    function match_MalformedCloseTag($stack = array())
5556
    {
5557
        $matchrule = "MalformedCloseTag";
5558
        $result = $this->construct($matchrule, $matchrule, null);
5559
        $_680 = null;
5560
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
5561
            if (( $subres = $this->literal('<%') ) !== false) {
5562
                $result["text"] .= $subres;
5563
            } else {
5564
                $_680 = false;
5565
                break;
5566
            }
5567
            if (( $subres = $this->whitespace() ) !== false) {
5568
                $result["text"] .= $subres;
5569
            }
5570
            $stack[] = $result;
5571
            $result = $this->construct($matchrule, "Tag");
5572
            $_674 = null;
5573
            do {
5574
                if (( $subres = $this->literal('end_') ) !== false) {
5575
                    $result["text"] .= $subres;
5576
                } else {
5577
                    $_674 = false;
5578
                    break;
5579
                }
5580
                $matcher = 'match_'.'Word';
5581
                $key = $matcher;
5582
                $pos = $this->pos;
5583
                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5584
                if ($subres !== false) {
5585
                    $this->store($result, $subres, "Word");
5586
                } else {
5587
                    $_674 = false;
5588
                    break;
5589
                }
5590
                $_674 = true;
5591
                break;
5592
            } while (0);
5593
            if ($_674 === true) {
5594
                $subres = $result;
5595
                $result = array_pop($stack);
5596
                $this->store($result, $subres, 'Tag');
5597
            }
5598
            if ($_674 === false) {
5599
                $result = array_pop($stack);
5600
                $_680 = false;
5601
                break;
5602
            }
5603
            $res_679 = $result;
5604
            $pos_679 = $this->pos;
5605
            $_678 = null;
5606
            do {
5607
                if (( $subres = $this->whitespace() ) !== false) {
5608
                    $result["text"] .= $subres;
5609
                }
5610
                if (( $subres = $this->literal('%>') ) !== false) {
5611
                    $result["text"] .= $subres;
5612
                } else {
5613
                    $_678 = false;
5614
                    break;
5615
                }
5616
                $_678 = true;
5617
                break;
5618
            } while (0);
5619
            if ($_678 === true) {
5620
                $result = $res_679;
5621
                $this->pos = $pos_679;
5622
                $_680 = false;
5623
                break;
5624
            }
5625
            if ($_678 === false) {
5626
                $result = $res_679;
5627
                $this->pos = $pos_679;
5628
            }
5629
            $_680 = true;
5630
            break;
5631
        } while (0);
5632
        if ($_680 === true) {
5633
            return $this->finalise($result);
5634
        }
5635
        if ($_680 === false) {
5636
            return false;
5637
        }
5638
    }
5639
5640
5641
5642
    function MalformedCloseTag__finalise(&$res)
5643
    {
5644
        $tag = $res['Tag']['text'];
5645
        throw new SSTemplateParseException("Malformed closing block tag $tag. Perhaps you have tried to pass an " .
5646
            "argument to one?", $this);
5647
    }
5648
5649
    /* MalformedBlock: MalformedOpenTag | MalformedCloseTag */
5650
    protected $match_MalformedBlock_typestack = array('MalformedBlock');
5651
    function match_MalformedBlock($stack = array())
5652
    {
5653
        $matchrule = "MalformedBlock";
5654
        $result = $this->construct($matchrule, $matchrule, null);
5655
        $_685 = null;
5656
        do {
0 ignored issues
show
Unused Code introduced by
do { $res_682 = $res... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
5657
            $res_682 = $result;
5658
            $pos_682 = $this->pos;
5659
            $matcher = 'match_'.'MalformedOpenTag';
5660
            $key = $matcher;
5661
            $pos = $this->pos;
5662
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5663
            if ($subres !== false) {
5664
                $this->store($result, $subres);
5665
                $_685 = true;
5666
                break;
5667
            }
5668
            $result = $res_682;
5669
            $this->pos = $pos_682;
5670
            $matcher = 'match_'.'MalformedCloseTag';
5671
            $key = $matcher;
5672
            $pos = $this->pos;
5673
            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5674
            if ($subres !== false) {
5675
                $this->store($result, $subres);
5676
                $_685 = true;
5677
                break;
5678
            }
5679
            $result = $res_682;
5680
            $this->pos = $pos_682;
5681
            $_685 = false;
5682
            break;
5683
        } while (0);
5684
        if ($_685 === true) {
5685
            return $this->finalise($result);
5686
        }
5687
        if ($_685 === false) {
5688
            return false;
5689
        }
5690
    }
5691
5692
5693
5694
5695
    /* Comment: "<%--" (!"--%>" /(?s)./)+ "--%>" */
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
5696
    protected $match_Comment_typestack = array('Comment');
5697
    function match_Comment($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
5698
    {
5699
        $matchrule = "Comment";
5700
        $result = $this->construct($matchrule, $matchrule, null);
5701
        $_693 = null;
5702
        do {
0 ignored issues
show
Unused Code introduced by
do { if (($subres = ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
5703
            if (( $subres = $this->literal('<%--') ) !== false) {
5704
                $result["text"] .= $subres;
5705
            } else {
5706
                $_693 = false;
5707
                break;
5708
            }
5709
            $count = 0;
5710
            while (true) {
5711
                $res_691 = $result;
5712
                $pos_691 = $this->pos;
5713
                $_690 = null;
5714
                do {
5715
                    $res_688 = $result;
5716
                    $pos_688 = $this->pos;
5717
                    if (( $subres = $this->literal('--%>') ) !== false) {
5718
                        $result["text"] .= $subres;
5719
                        $result = $res_688;
5720
                        $this->pos = $pos_688;
5721
                        $_690 = false;
5722
                        break;
5723
                    } else {
5724
                        $result = $res_688;
5725
                        $this->pos = $pos_688;
5726
                    }
5727
                    if (( $subres = $this->rx('/(?s)./') ) !== false) {
5728
                        $result["text"] .= $subres;
5729
                    } else {
5730
                        $_690 = false;
5731
                        break;
5732
                    }
5733
                    $_690 = true;
5734
                    break;
5735
                } while (0);
5736
                if ($_690 === false) {
5737
                    $result = $res_691;
5738
                    $this->pos = $pos_691;
5739
                    unset($res_691);
5740
                    unset($pos_691);
5741
                    break;
5742
                }
5743
                $count += 1;
5744
            }
5745
            if ($count > 0) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
5746
            } else {
5747
                $_693 = false;
5748
                break;
5749
            }
5750
            if (( $subres = $this->literal('--%>') ) !== false) {
5751
                $result["text"] .= $subres;
5752
            } else {
5753
                $_693 = false;
5754
                break;
5755
            }
5756
            $_693 = true;
5757
            break;
5758
        } while (0);
5759
        if ($_693 === true) {
5760
            return $this->finalise($result);
5761
        }
5762
        if ($_693 === false) {
5763
            return false;
5764
        }
5765
    }
5766
5767
5768
5769
    function Comment__construct(&$res)
5770
    {
5771
        $res['php'] = '';
5772
    }
5773
5774
    /* TopTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
5775
	OpenBlock |  MalformedBlock | MismatchedEndBlock  | Injection | Text)+ */
5776
    protected $match_TopTemplate_typestack = array('TopTemplate','Template');
5777
    function match_TopTemplate($stack = array())
5778
    {
5779
        $matchrule = "TopTemplate";
5780
        $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'Template'));
5781
        $count = 0;
5782
        while (true) {
5783
            $res_749 = $result;
5784
            $pos_749 = $this->pos;
5785
            $_748 = null;
5786
            do {
0 ignored issues
show
Unused Code introduced by
do { $_746 = null; ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
5787
                $_746 = null;
5788
                do {
5789
                    $res_695 = $result;
5790
                    $pos_695 = $this->pos;
5791
                    $matcher = 'match_'.'Comment';
5792
                    $key = $matcher;
5793
                    $pos = $this->pos;
5794
                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5795
                    if ($subres !== false) {
5796
                        $this->store($result, $subres);
5797
                        $_746 = true;
5798
                        break;
5799
                    }
5800
                    $result = $res_695;
5801
                    $this->pos = $pos_695;
5802
                    $_744 = null;
5803
                    do {
5804
                        $res_697 = $result;
5805
                        $pos_697 = $this->pos;
5806
                        $matcher = 'match_'.'Translate';
5807
                        $key = $matcher;
5808
                        $pos = $this->pos;
5809
                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5810
                        if ($subres !== false) {
5811
                            $this->store($result, $subres);
5812
                            $_744 = true;
5813
                            break;
5814
                        }
5815
                        $result = $res_697;
5816
                        $this->pos = $pos_697;
5817
                        $_742 = null;
5818
                        do {
5819
                            $res_699 = $result;
5820
                            $pos_699 = $this->pos;
5821
                            $matcher = 'match_'.'If';
5822
                            $key = $matcher;
5823
                            $pos = $this->pos;
5824
                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5825
                            if ($subres !== false) {
5826
                                $this->store($result, $subres);
5827
                                $_742 = true;
5828
                                break;
5829
                            }
5830
                            $result = $res_699;
5831
                            $this->pos = $pos_699;
5832
                            $_740 = null;
5833
                            do {
5834
                                $res_701 = $result;
5835
                                $pos_701 = $this->pos;
5836
                                $matcher = 'match_'.'Require';
5837
                                $key = $matcher;
5838
                                $pos = $this->pos;
5839
                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5840
                                if ($subres !== false) {
5841
                                    $this->store($result, $subres);
5842
                                    $_740 = true;
5843
                                    break;
5844
                                }
5845
                                $result = $res_701;
5846
                                $this->pos = $pos_701;
5847
                                $_738 = null;
5848
                                do {
5849
                                    $res_703 = $result;
5850
                                    $pos_703 = $this->pos;
5851
                                    $matcher = 'match_'.'CacheBlock';
5852
                                    $key = $matcher;
5853
                                    $pos = $this->pos;
5854
                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5855
                                    if ($subres !== false) {
5856
                                        $this->store($result, $subres);
5857
                                        $_738 = true;
5858
                                        break;
5859
                                    }
5860
                                    $result = $res_703;
5861
                                    $this->pos = $pos_703;
5862
                                    $_736 = null;
5863
                                    do {
5864
                                        $res_705 = $result;
5865
                                        $pos_705 = $this->pos;
5866
                                        $matcher = 'match_'.'UncachedBlock';
5867
                                        $key = $matcher;
5868
                                        $pos = $this->pos;
5869
                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5870
                                        if ($subres !== false) {
5871
                                            $this->store($result, $subres);
5872
                                            $_736 = true;
5873
                                            break;
5874
                                        }
5875
                                        $result = $res_705;
5876
                                        $this->pos = $pos_705;
5877
                                        $_734 = null;
5878
                                        do {
5879
                                            $res_707 = $result;
5880
                                            $pos_707 = $this->pos;
5881
                                            $matcher = 'match_'.'OldI18NTag';
5882
                                            $key = $matcher;
5883
                                            $pos = $this->pos;
5884
                                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5885
                                            if ($subres !== false) {
5886
                                                $this->store($result, $subres);
5887
                                                $_734 = true;
5888
                                                break;
5889
                                            }
5890
                                            $result = $res_707;
5891
                                            $this->pos = $pos_707;
5892
                                            $_732 = null;
5893
                                            do {
5894
                                                $res_709 = $result;
5895
                                                $pos_709 = $this->pos;
5896
                                                $matcher = 'match_'.'Include';
5897
                                                $key = $matcher;
5898
                                                $pos = $this->pos;
5899
                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5900
                                                if ($subres !== false) {
5901
                                                    $this->store($result, $subres);
5902
                                                    $_732 = true;
5903
                                                    break;
5904
                                                }
5905
                                                $result = $res_709;
5906
                                                $this->pos = $pos_709;
5907
                                                $_730 = null;
5908
                                                do {
5909
                                                    $res_711 = $result;
5910
                                                    $pos_711 = $this->pos;
5911
                                                    $matcher = 'match_'.'ClosedBlock';
5912
                                                    $key = $matcher;
5913
                                                    $pos = $this->pos;
5914
                                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5915
                                                    if ($subres !== false) {
5916
                                                        $this->store($result, $subres);
5917
                                                        $_730 = true;
5918
                                                        break;
5919
                                                    }
5920
                                                    $result = $res_711;
5921
                                                    $this->pos = $pos_711;
5922
                                                    $_728 = null;
5923
                                                    do {
5924
                                                        $res_713 = $result;
5925
                                                        $pos_713 = $this->pos;
5926
                                                        $matcher = 'match_'.'OpenBlock';
5927
                                                        $key = $matcher;
5928
                                                        $pos = $this->pos;
5929
                                                        $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5930
                                                        if ($subres !== false) {
5931
                                                            $this->store($result, $subres);
5932
                                                            $_728 = true;
5933
                                                            break;
5934
                                                        }
5935
                                                        $result = $res_713;
5936
                                                        $this->pos = $pos_713;
5937
                                                        $_726 = null;
5938
                                                        do {
5939
                                                            $res_715 = $result;
5940
                                                            $pos_715 = $this->pos;
5941
                                                            $matcher = 'match_'.'MalformedBlock';
5942
                                                            $key = $matcher;
5943
                                                            $pos = $this->pos;
5944
                                                            $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5945
                                                            if ($subres !== false) {
5946
                                                                $this->store($result, $subres);
5947
                                                                $_726 = true;
5948
                                                                break;
5949
                                                            }
5950
                                                            $result = $res_715;
5951
                                                            $this->pos = $pos_715;
5952
                                                            $_724 = null;
5953
                                                            do {
5954
                                                                $res_717 = $result;
5955
                                                                $pos_717 = $this->pos;
5956
                                                                $matcher = 'match_'.'MismatchedEndBlock';
5957
                                                                $key = $matcher;
5958
                                                                $pos = $this->pos;
5959
                                                                $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5960
                                                                if ($subres !== false) {
5961
                                                                    $this->store($result, $subres);
5962
                                                                    $_724 = true;
5963
                                                                    break;
5964
                                                                }
5965
                                                                $result = $res_717;
5966
                                                                $this->pos = $pos_717;
5967
                                                                $_722 = null;
5968
                                                                do {
5969
                                                                    $res_719 = $result;
5970
                                                                    $pos_719 = $this->pos;
5971
                                                                    $matcher = 'match_'.'Injection';
5972
                                                                    $key = $matcher;
5973
                                                                    $pos = $this->pos;
5974
                                                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5975
                                                                    if ($subres !== false) {
5976
                                                                        $this->store($result, $subres);
5977
                                                                        $_722 = true;
5978
                                                                        break;
5979
                                                                    }
5980
                                                                    $result = $res_719;
5981
                                                                    $this->pos = $pos_719;
5982
                                                                    $matcher = 'match_'.'Text';
5983
                                                                    $key = $matcher;
5984
                                                                    $pos = $this->pos;
5985
                                                                    $subres = ( $this->packhas($key, $pos) ? $this->packread($key, $pos) : $this->packwrite($key, $pos, $this->$matcher(array_merge($stack, array($result)))) );
5986
                                                                    if ($subres !== false) {
5987
                                                                        $this->store($result, $subres);
5988
                                                                        $_722 = true;
5989
                                                                        break;
5990
                                                                    }
5991
                                                                    $result = $res_719;
5992
                                                                    $this->pos = $pos_719;
5993
                                                                    $_722 = false;
5994
                                                                    break;
5995
                                                                } while (0);
5996
                                                                if ($_722 === true) {
5997
                                                                    $_724 = true;
5998
                                                                    break;
5999
                                                                }
6000
                                                                $result = $res_717;
6001
                                                                $this->pos = $pos_717;
6002
                                                                $_724 = false;
6003
                                                                break;
6004
                                                            } while (0);
6005
                                                            if ($_724 === true) {
6006
                                                                $_726 = true;
6007
                                                                break;
6008
                                                            }
6009
                                                            $result = $res_715;
6010
                                                            $this->pos = $pos_715;
6011
                                                            $_726 = false;
6012
                                                            break;
6013
                                                        } while (0);
6014
                                                        if ($_726 === true) {
6015
                                                            $_728 = true;
6016
                                                            break;
6017
                                                        }
6018
                                                        $result = $res_713;
6019
                                                        $this->pos = $pos_713;
6020
                                                        $_728 = false;
6021
                                                        break;
6022
                                                    } while (0);
6023
                                                    if ($_728 === true) {
6024
                                                        $_730 = true;
6025
                                                        break;
6026
                                                    }
6027
                                                    $result = $res_711;
6028
                                                    $this->pos = $pos_711;
6029
                                                    $_730 = false;
6030
                                                    break;
6031
                                                } while (0);
6032
                                                if ($_730 === true) {
6033
                                                    $_732 = true;
6034
                                                    break;
6035
                                                }
6036
                                                $result = $res_709;
6037
                                                $this->pos = $pos_709;
6038
                                                $_732 = false;
6039
                                                break;
6040
                                            } while (0);
6041
                                            if ($_732 === true) {
6042
                                                $_734 = true;
6043
                                                break;
6044
                                            }
6045
                                            $result = $res_707;
6046
                                            $this->pos = $pos_707;
6047
                                            $_734 = false;
6048
                                            break;
6049
                                        } while (0);
6050
                                        if ($_734 === true) {
6051
                                            $_736 = true;
6052
                                            break;
6053
                                        }
6054
                                        $result = $res_705;
6055
                                        $this->pos = $pos_705;
6056
                                        $_736 = false;
6057
                                        break;
6058
                                    } while (0);
6059
                                    if ($_736 === true) {
6060
                                        $_738 = true;
6061
                                        break;
6062
                                    }
6063
                                    $result = $res_703;
6064
                                    $this->pos = $pos_703;
6065
                                    $_738 = false;
6066
                                    break;
6067
                                } while (0);
6068
                                if ($_738 === true) {
6069
                                    $_740 = true;
6070
                                    break;
6071
                                }
6072
                                $result = $res_701;
6073
                                $this->pos = $pos_701;
6074
                                $_740 = false;
6075
                                break;
6076
                            } while (0);
6077
                            if ($_740 === true) {
6078
                                $_742 = true;
6079
                                break;
6080
                            }
6081
                            $result = $res_699;
6082
                            $this->pos = $pos_699;
6083
                            $_742 = false;
6084
                            break;
6085
                        } while (0);
6086
                        if ($_742 === true) {
6087
                            $_744 = true;
6088
                            break;
6089
                        }
6090
                        $result = $res_697;
6091
                        $this->pos = $pos_697;
6092
                        $_744 = false;
6093
                        break;
6094
                    } while (0);
6095
                    if ($_744 === true) {
6096
                        $_746 = true;
6097
                        break;
6098
                    }
6099
                    $result = $res_695;
6100
                    $this->pos = $pos_695;
6101
                    $_746 = false;
6102
                    break;
6103
                } while (0);
6104
                if ($_746 === false) {
6105
                    $_748 = false;
6106
                    break;
6107
                }
6108
                $_748 = true;
6109
                break;
6110
            } while (0);
6111
            if ($_748 === false) {
6112
                $result = $res_749;
6113
                $this->pos = $pos_749;
6114
                unset($res_749);
6115
                unset($pos_749);
6116
                break;
6117
            }
6118
            $count += 1;
6119
        }
6120
        if ($count > 0) {
6121
            return $this->finalise($result);
6122
        } else {
6123
            return false;
6124
        }
6125
    }
6126
6127
6128
6129
6130
    /**
6131
     * The TopTemplate also includes the opening stanza to start off the template
6132
     */
6133
    function TopTemplate__construct(&$res)
6134
    {
6135
        $res['php'] = "<?php" . PHP_EOL;
6136
    }
6137
6138
    /* Text: (
0 ignored issues
show
Unused Code Comprehensibility introduced by
41% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
6139
		/ [^<${\\]+ / |
6140
		/ (\\.) / |
6141
		'<' !'%' |
6142
		'$' !(/[A-Za-z_]/) |
6143
		'{' !'$' |
6144
		'{$' !(/[A-Za-z_]/)
6145
	)+ */
6146
    protected $match_Text_typestack = array('Text');
6147
    function match_Text($stack = array())
0 ignored issues
show
Unused Code introduced by
The parameter $stack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
6148
    {
6149
        $matchrule = "Text";
6150
        $result = $this->construct($matchrule, $matchrule, null);
6151
        $count = 0;
6152
        while (true) {
6153
            $res_788 = $result;
6154
            $pos_788 = $this->pos;
6155
            $_787 = null;
6156
            do {
0 ignored issues
show
Unused Code introduced by
do { $_785 = null; ... break; } while (0); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
6157
                $_785 = null;
6158
                do {
6159
                    $res_750 = $result;
6160
                    $pos_750 = $this->pos;
6161
                    if (( $subres = $this->rx('/ [^<${\\\\]+ /') ) !== false) {
6162
                        $result["text"] .= $subres;
6163
                        $_785 = true;
6164
                        break;
6165
                    }
6166
                    $result = $res_750;
6167
                    $this->pos = $pos_750;
6168
                    $_783 = null;
6169
                    do {
6170
                        $res_752 = $result;
6171
                        $pos_752 = $this->pos;
6172
                        if (( $subres = $this->rx('/ (\\\\.) /') ) !== false) {
6173
                            $result["text"] .= $subres;
6174
                            $_783 = true;
6175
                            break;
6176
                        }
6177
                        $result = $res_752;
6178
                        $this->pos = $pos_752;
6179
                        $_781 = null;
6180
                        do {
6181
                            $res_754 = $result;
6182
                            $pos_754 = $this->pos;
6183
                            $_757 = null;
6184
                            do {
6185
                                if (substr($this->string, $this->pos, 1) == '<') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
6186
                                    $this->pos += 1;
6187
                                    $result["text"] .= '<';
6188
                                } else {
6189
                                    $_757 = false;
6190
                                    break;
6191
                                }
6192
                                $res_756 = $result;
6193
                                $pos_756 = $this->pos;
6194
                                if (substr($this->string, $this->pos, 1) == '%') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
6195
                                    $this->pos += 1;
6196
                                    $result["text"] .= '%';
6197
                                    $result = $res_756;
6198
                                    $this->pos = $pos_756;
6199
                                    $_757 = false;
6200
                                    break;
6201
                                } else {
6202
                                    $result = $res_756;
6203
                                    $this->pos = $pos_756;
6204
                                }
6205
                                $_757 = true;
6206
                                break;
6207
                            } while (0);
6208
                            if ($_757 === true) {
6209
                                $_781 = true;
6210
                                break;
6211
                            }
6212
                            $result = $res_754;
6213
                            $this->pos = $pos_754;
6214
                            $_779 = null;
6215
                            do {
6216
                                $res_759 = $result;
6217
                                $pos_759 = $this->pos;
6218
                                $_764 = null;
6219
                                do {
6220
                                    if (substr($this->string, $this->pos, 1) == '$') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
6221
                                        $this->pos += 1;
6222
                                        $result["text"] .= '$';
6223
                                    } else {
6224
                                        $_764 = false;
6225
                                        break;
6226
                                    }
6227
                                    $res_763 = $result;
6228
                                    $pos_763 = $this->pos;
6229
                                    $_762 = null;
6230
                                    do {
6231
                                        if (( $subres = $this->rx('/[A-Za-z_]/') ) !== false) {
6232
                                            $result["text"] .= $subres;
6233
                                        } else {
6234
                                            $_762 = false;
6235
                                            break;
6236
                                        }
6237
                                        $_762 = true;
6238
                                        break;
6239
                                    } while (0);
6240
                                    if ($_762 === true) {
6241
                                        $result = $res_763;
6242
                                        $this->pos = $pos_763;
6243
                                        $_764 = false;
6244
                                        break;
6245
                                    }
6246
                                    if ($_762 === false) {
6247
                                        $result = $res_763;
6248
                                        $this->pos = $pos_763;
6249
                                    }
6250
                                    $_764 = true;
6251
                                    break;
6252
                                } while (0);
6253
                                if ($_764 === true) {
6254
                                    $_779 = true;
6255
                                    break;
6256
                                }
6257
                                $result = $res_759;
6258
                                $this->pos = $pos_759;
6259
                                $_777 = null;
6260
                                do {
6261
                                    $res_766 = $result;
6262
                                    $pos_766 = $this->pos;
6263
                                    $_769 = null;
6264
                                    do {
6265
                                        if (substr($this->string, $this->pos, 1) == '{') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
6266
                                            $this->pos += 1;
6267
                                            $result["text"] .= '{';
6268
                                        } else {
6269
                                            $_769 = false;
6270
                                            break;
6271
                                        }
6272
                                        $res_768 = $result;
6273
                                        $pos_768 = $this->pos;
6274
                                        if (substr($this->string, $this->pos, 1) == '$') {
0 ignored issues
show
Bug introduced by
The property string does not seem to exist. Did you mean match_QuotedString_typestack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
6275
                                            $this->pos += 1;
6276
                                            $result["text"] .= '$';
6277
                                            $result = $res_768;
6278
                                            $this->pos = $pos_768;
6279
                                            $_769 = false;
6280
                                            break;
6281
                                        } else {
6282
                                            $result = $res_768;
6283
                                            $this->pos = $pos_768;
6284
                                        }
6285
                                        $_769 = true;
6286
                                        break;
6287
                                    } while (0);
6288
                                    if ($_769 === true) {
6289
                                        $_777 = true;
6290
                                        break;
6291
                                    }
6292
                                    $result = $res_766;
6293
                                    $this->pos = $pos_766;
6294
                                    $_775 = null;
6295
                                    do {
6296
                                        if (( $subres = $this->literal('{$') ) !== false) {
6297
                                            $result["text"] .= $subres;
6298
                                        } else {
6299
                                            $_775 = false;
6300
                                            break;
6301
                                        }
6302
                                        $res_774 = $result;
6303
                                        $pos_774 = $this->pos;
6304
                                        $_773 = null;
6305
                                        do {
6306
                                            if (( $subres = $this->rx('/[A-Za-z_]/') ) !== false) {
6307
                                                $result["text"] .= $subres;
6308
                                            } else {
6309
                                                $_773 = false;
6310
                                                break;
6311
                                            }
6312
                                            $_773 = true;
6313
                                            break;
6314
                                        } while (0);
6315
                                        if ($_773 === true) {
6316
                                            $result = $res_774;
6317
                                            $this->pos = $pos_774;
6318
                                            $_775 = false;
6319
                                            break;
6320
                                        }
6321
                                        if ($_773 === false) {
6322
                                            $result = $res_774;
6323
                                            $this->pos = $pos_774;
6324
                                        }
6325
                                        $_775 = true;
6326
                                        break;
6327
                                    } while (0);
6328
                                    if ($_775 === true) {
6329
                                        $_777 = true;
6330
                                        break;
6331
                                    }
6332
                                    $result = $res_766;
6333
                                    $this->pos = $pos_766;
6334
                                    $_777 = false;
6335
                                    break;
6336
                                } while (0);
6337
                                if ($_777 === true) {
6338
                                    $_779 = true;
6339
                                    break;
6340
                                }
6341
                                $result = $res_759;
6342
                                $this->pos = $pos_759;
6343
                                $_779 = false;
6344
                                break;
6345
                            } while (0);
6346
                            if ($_779 === true) {
6347
                                $_781 = true;
6348
                                break;
6349
                            }
6350
                            $result = $res_754;
6351
                            $this->pos = $pos_754;
6352
                            $_781 = false;
6353
                            break;
6354
                        } while (0);
6355
                        if ($_781 === true) {
6356
                            $_783 = true;
6357
                            break;
6358
                        }
6359
                        $result = $res_752;
6360
                        $this->pos = $pos_752;
6361
                        $_783 = false;
6362
                        break;
6363
                    } while (0);
6364
                    if ($_783 === true) {
6365
                        $_785 = true;
6366
                        break;
6367
                    }
6368
                    $result = $res_750;
6369
                    $this->pos = $pos_750;
6370
                    $_785 = false;
6371
                    break;
6372
                } while (0);
6373
                if ($_785 === false) {
6374
                    $_787 = false;
6375
                    break;
6376
                }
6377
                $_787 = true;
6378
                break;
6379
            } while (0);
6380
            if ($_787 === false) {
6381
                $result = $res_788;
6382
                $this->pos = $pos_788;
6383
                unset($res_788);
6384
                unset($pos_788);
6385
                break;
6386
            }
6387
            $count += 1;
6388
        }
6389
        if ($count > 0) {
6390
            return $this->finalise($result);
6391
        } else {
6392
            return false;
6393
        }
6394
    }
6395
6396
6397
6398
6399
    /**
6400
     * We convert text
6401
     */
6402
    function Text__finalise(&$res)
6403
    {
6404
        $text = $res['text'];
6405
6406
        // Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes
6407
        $text = stripslashes($text);
6408
        $text = addcslashes($text, '\'\\');
6409
6410
        // TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this
6411
        // non-dynamically calculated
6412
        $code = <<<'EOC'
6413
(\SilverStripe\View\SSViewer::config()->get('rewrite_hash_links')
6414
	? \SilverStripe\Core\Convert::raw2att( preg_replace("/^(\\/)+/", "/", $_SERVER['REQUEST_URI'] ) )
6415
	: "")
6416
EOC;
6417
        // Because preg_replace replacement requires escaped slashes, addcslashes here
6418
        $text = preg_replace(
6419
            '/(<a[^>]+href *= *)"#/i',
6420
            '\\1"\' . ' . addcslashes($code, '\\')  . ' . \'#',
6421
            $text
6422
        );
6423
6424
        $res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL;
6425
    }
6426
6427
    /******************
6428
	 * Here ends the parser itself. Below are utility methods to use the parser
6429
	 */
6430
6431
    /**
6432
     * Compiles some passed template source code into the php code that will execute as per the template source.
6433
     *
6434
     * @throws SSTemplateParseException
6435
     * @param string $string The source of the template
6436
     * @param string $templateName The name of the template, normally the filename the template source was loaded from
6437
     * @param bool $includeDebuggingComments True is debugging comments should be included in the output
6438
     * @param bool $topTemplate True if this is a top template, false if it's just a template
6439
     * @return mixed|string The php that, when executed (via include or exec) will behave as per the template source
6440
     */
6441
    public function compileString($string, $templateName = "", $includeDebuggingComments = false, $topTemplate = true)
6442
    {
6443
        if (!trim($string)) {
6444
            $code = '';
6445
        } else {
6446
            parent::__construct($string);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (__construct() instead of compileString()). Are you sure this is correct? If so, you might want to change this to $this->__construct().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
6447
6448
            $this->includeDebuggingComments = $includeDebuggingComments;
6449
6450
            // Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF
6451
            // (and other encodings) properly
6452
            if (substr($string, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
6453
                $this->pos = 3;
6454
            }
6455
6456
            // Match the source against the parser
6457
            if ($topTemplate) {
6458
                $result = $this->match_TopTemplate();
6459
            } else {
6460
                $result = $this->match_Template();
6461
            }
6462
            if (!$result) {
6463
                throw new SSTemplateParseException('Unexpected problem parsing template', $this);
6464
            }
6465
6466
            // Get the result
6467
            $code = $result['php'];
6468
        }
6469
6470
        // Include top level debugging comments if desired
6471
        if ($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
6472
            $code = $this->includeDebuggingComments($code, $templateName);
6473
        }
6474
6475
        return $code;
6476
    }
6477
6478
    /**
6479
     * @param string $code
6480
     * @return string $code
6481
     */
6482
    protected function includeDebuggingComments($code, $templateName)
6483
    {
6484
        // If this template contains a doctype, put it right after it,
6485
        // if not, put it after the <html> tag to avoid IE glitches
6486
        if (stripos($code, "<!doctype") !== false) {
6487
            $code = preg_replace('/(<!doctype[^>]*("[^"]")*[^>]*>)/im', "$1\r\n<!-- template $templateName -->", $code);
6488
            $code .= "\r\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';';
6489
        } elseif (stripos($code, "<html") !== false) {
6490
            $code = preg_replace_callback('/(.*)(<html[^>]*>)(.*)/i', function ($matches) use ($templateName) {
6491
                if (stripos($matches[3], '<!--') === false && stripos($matches[3], '-->') !== false) {
6492
                    // after this <html> tag there is a comment close but no comment has been opened
6493
                    // this most likely means that this <html> tag is inside a comment
6494
                    // we should not add a comment inside a comment (invalid html)
6495
                    // lets append it at the end of the comment
6496
                    // an example case for this is the html5boilerplate: <!--[if IE]><html class="ie"><![endif]-->
6497
                    return $matches[0];
6498
                } else {
6499
                    // all other cases, add the comment and return it
6500
                    return "{$matches[1]}{$matches[2]}<!-- template $templateName -->{$matches[3]}";
6501
                }
6502
            }, $code);
6503
            $code = preg_replace('/(<\/html[^>]*>)/i', "<!-- end template $templateName -->$1", $code);
6504
        } else {
6505
            $code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
6506
                ' -->\';' . "\r\n", $code);
6507
            $code .= "\r\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';';
6508
        }
6509
        return $code;
6510
    }
6511
6512
    /**
6513
     * Compiles some file that contains template source code, and returns the php code that will execute as per that
6514
     * source
6515
     *
6516
     * @static
6517
     * @param  $template - A file path that contains template source code
6518
     * @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source
6519
     */
6520
    public function compileFile($template)
6521
    {
6522
        return $this->compileString(file_get_contents($template), $template);
6523
    }
6524
}
6525