TemplateLexer::yy_r3_7()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Smarty\Lexer;
4
5
/*
6
 * This file is part of Smarty.
7
 *
8
 * (c) 2015 Uwe Tews
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
/**
15
 * TemplateLexer
16
 * This is the template file lexer.
17
 * It is generated from the TemplateLexer.plex file
18
 *
19
 *
20
 * @author Uwe Tews <[email protected]>
21
 */
22
class TemplateLexer
23
{
24
    /**
25
     * Source
26
     *
27
     * @var string
28
     */
29
    public $data;
30
31
    /**
32
     * Source length
33
     *
34
     * @var int
35
     */
36
    public $dataLength = null;
37
38
    /**
39
     * byte counter
40
     *
41
     * @var int
42
     */
43
    public $counter;
44
45
    /**
46
     * token number
47
     *
48
     * @var int
49
     */
50
    public $token;
51
52
    /**
53
     * token value
54
     *
55
     * @var string
56
     */
57
    public $value;
58
59
    /**
60
     * current line
61
     *
62
     * @var int
63
     */
64
    public $line;
65
66
    /**
67
     * tag start line
68
     *
69
     * @var
70
     */
71
    public $taglineno;
72
73
   /**
74
     * state number
75
     *
76
     * @var int
77
     */
78
    public $state = 1;
79
80
    /**
81
     * Smarty object
0 ignored issues
show
Bug introduced by
The type Smarty\Lexer\Smarty was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
82
     *
83
     * @var Smarty
84
     */
85
    public $smarty = null;
86
87
    /**
88
     * compiler object
89
     *
90
     * @var \Smarty\Compiler\Template
91
     */
92
    public $compiler = null;
93
94
    /**
95
     * trace file
96
     *
97
     * @var resource
98
     */
99
    public $yyTraceFILE;
100
101
    /**
102
     * trace prompt
103
     *
104
     * @var string
105
     */
106
    public $yyTracePrompt;
107
108
    /**
109
     * XML flag true while processing xml
110
     *
111
     * @var bool
112
     */
113
    public $is_xml = false;
114
115
    /**
116
     * state names
117
     *
118
     * @var array
119
     */
120
    public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',);
121
122
    /**
123
     * token names
124
     *
125
     * @var array
126
     */
127
    public $smarty_token_names = array(        // Text for parser error messages
128
                                               'NOT'         => '(!,not)',
129
                                               'OPENP'       => '(',
130
                                               'CLOSEP'      => ')',
131
                                               'OPENB'       => '[',
132
                                               'CLOSEB'      => ']',
133
                                               'PTR'         => '->',
134
                                               'APTR'        => '=>',
135
                                               'EQUAL'       => '=',
136
                                               'NUMBER'      => 'number',
137
                                               'UNIMATH'     => '+" , "-',
138
                                               'MATH'        => '*" , "/" , "%',
139
                                               'INCDEC'      => '++" , "--',
140
                                               'SPACE'       => ' ',
141
                                               'DOLLAR'      => '$',
142
                                               'SEMICOLON'   => ';',
143
                                               'COLON'       => ':',
144
                                               'DOUBLECOLON' => '::',
145
                                               'AT'          => '@',
146
                                               'HATCH'       => '#',
147
                                               'QUOTE'       => '"',
148
                                               'BACKTICK'    => '`',
149
                                               'VERT'        => '"|" modifier',
150
                                               'DOT'         => '.',
151
                                               'COMMA'       => '","',
152
                                               'QMARK'       => '"?"',
153
                                               'ID'          => 'id, name',
154
                                               'TEXT'        => 'text',
155
                                               'LDELSLASH'   => '{/..} closing tag',
156
                                               'LDEL'        => '{...} Smarty tag',
157
                                               'COMMENT'     => 'comment',
158
                                               'AS'          => 'as',
159
                                               'TO'          => 'to',
160
                                               'LOGOP'       => '"<", "==" ... logical operator',
161
                                               'TLOGOP'      => '"lt", "eq" ... logical operator; "is div by" ... if condition',
162
                                               'SCOND'       => '"is even" ... if condition',
163
    );
164
165
    /**
166
     * literal tag nesting level
167
     *
168
     * @var int
169
     */
170
    private $literal_cnt = 0;
171
172
    /**
173
     * preg token pattern for state TEXT
174
     *
175
     * @var string
176
     */
177
    private $yy_global_pattern1 = null;
178
179
    /**
180
     * preg token pattern for state TAG
181
     *
182
     * @var string
183
     */
184
    private $yy_global_pattern2 = null;
185
186
    /**
187
     * preg token pattern for state TAGBODY
188
     *
189
     * @var string
190
     */
191
    private $yy_global_pattern3 = null;
192
193
    /**
194
     * preg token pattern for state LITERAL
195
     *
196
     * @var string
197
     */
198
    private $yy_global_pattern4 = null;
199
200
    /**
201
     * preg token pattern for state DOUBLEQUOTEDSTRING
202
     *
203
     * @var null
204
     */
205
    private $yy_global_pattern5 = null;
206
207
    /**
208
     * preg token pattern for text
209
     *
210
     * @var null
211
     */
212
    private $yy_global_text = null;
213
214
    /**
215
     * preg token pattern for literal
216
     *
217
     * @var null
218
     */
219
    private $yy_global_literal = null;
220
221
    /**
222
     * constructor
223
     *
224
     * @param   string                             $source template source
225
     * @param \Smarty\Compiler\Template $compiler
226
     */
227
    public function __construct($source, \Smarty\Compiler\Template $compiler)
228
    {
229
        $this->data = $source;
230
        $this->dataLength = strlen($this->data);
231
        $this->counter = 0;
232
        if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) {
233
            $this->counter += strlen($match[0]);
234
        }
235
        $this->line = 1;
236
        $this->smarty = $compiler->getTemplate()->getSmarty();
0 ignored issues
show
Documentation Bug introduced by
It seems like $compiler->getTemplate()->getSmarty() of type Smarty\Smarty is incompatible with the declared type Smarty\Lexer\Smarty of property $smarty.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
237
        $this->compiler = $compiler;
238
        $this->compiler->initDelimiterPreg();
239
        $this->smarty_token_names['LDEL'] = $this->smarty->getLeftDelimiter();
240
        $this->smarty_token_names['RDEL'] = $this->smarty->getRightDelimiter();
241
    }
242
243
    /**
244
     * open lexer/parser trace file
245
     *
246
     */
247
    public function PrintTrace()
248
    {
249
        $this->yyTraceFILE = fopen('php://output', 'w');
250
        $this->yyTracePrompt = '<br>';
251
    }
252
253
   /**
254
     * replace placeholders with runtime preg  code
255
     *
256
     * @param string $preg
257
     *
258
     * @return string
259
     */
260
   public function replace($preg)
261
   {
262
        return $this->compiler->replaceDelimiter($preg);
263
   }
264
265
    /**
266
     * check if current value is an autoliteral left delimiter
267
     *
268
     * @return bool
269
     */
270
    public function isAutoLiteral()
271
    {
272
        return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ?
273
            strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false;
274
    }
275
276
     
277
    private $_yy_state = 1;
278
    private $_yy_stack = array();
279
280
    public function yylex()
281
    {
282
        return $this->{'yylex' . $this->_yy_state}();
283
    }
284
285
    public function yypushstate($state)
286
    {
287
        if ($this->yyTraceFILE) {
288
             fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
289
        }
290
        array_push($this->_yy_stack, $this->_yy_state);
291
        $this->_yy_state = $state;
292
        if ($this->yyTraceFILE) {
293
             fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
294
        }
295
    }
296
297
    public function yypopstate()
298
    {
299
       if ($this->yyTraceFILE) {
300
             fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt,  isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
301
        }
302
       $this->_yy_state = array_pop($this->_yy_stack);
303
        if ($this->yyTraceFILE) {
304
             fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
305
        }
306
307
    }
308
309
    public function yybegin($state)
310
    {
311
       $this->_yy_state = $state;
312
        if ($this->yyTraceFILE) {
313
             fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
314
        }
315
    }
316
317
318
     
319
    public function yylex1()
320
    {
321
        if (!isset($this->yy_global_pattern1)) {
322
            $this->yy_global_pattern1 = $this->replace("/\G([{][}])|\G((SMARTYldel)SMARTYal[*])|\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\S\s])/isS");
323
        }
324
        if (!isset($this->dataLength)) {
325
            $this->dataLength = strlen($this->data);
326
        }
327
        if ($this->counter >=  $this->dataLength) {
328
            return false; // end of input
329
        }
330
        
331
        do {
332
            if (preg_match($this->yy_global_pattern1,$this->data, $yymatches, 0, $this->counter)) {
333
                if (!isset($yymatches[ 0 ][1])) {
334
                   $yymatches = preg_grep("/(.|\s)+/", $yymatches);
335
                } else {
336
                    $yymatches = array_filter($yymatches);
337
                }
338
                if (empty($yymatches)) {
339
                    throw new Exception('Error: lexing failed because a rule matched' .
0 ignored issues
show
Bug introduced by
The type Smarty\Lexer\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
340
                        ' an empty string.  Input "' . substr($this->data,
341
                        $this->counter, 5) . '... state TEXT');
342
                }
343
                next($yymatches); // skip global match
344
                $this->token = key($yymatches); // token number
0 ignored issues
show
Documentation Bug introduced by
It seems like key($yymatches) can also be of type string. However, the property $token is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
345
                $this->value = current($yymatches); // token value
346
                $r = $this->{'yy_r1_' . $this->token}();
347
                if ($r === null) {
348
                    $this->counter += strlen($this->value);
349
                    $this->line += substr_count($this->value, "\n");
350
                    // accept this token
351
                    return true;
352
                } elseif ($r === true) {
353
                    // we have changed state
354
                    // process this token in the new state
355
                    return $this->yylex();
356
                } elseif ($r === false) {
357
                    $this->counter += strlen($this->value);
358
                    $this->line += substr_count($this->value, "\n");
359
                    if ($this->counter >=  $this->dataLength) {
360
                        return false; // end of input
361
                    }
362
                    // skip this token
363
                    continue;
364
                }            } else {
365
                throw new Exception('Unexpected input at line' . $this->line .
366
                    ': ' . $this->data[$this->counter]);
367
            }
368
            break;
369
        } while (true);
370
371
    } // end function
372
373
374
    const TEXT = 1;
375
    public function yy_r1_1()
376
    {
377
378
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
379
         }
380
    public function yy_r1_2()
381
    {
382
383
       $to = $this->dataLength;
384
       preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
385
        if (isset($match[0][1])) {
386
            $to = $match[0][1] + strlen($match[0][0]);
387
        } else {
388
            $this->compiler->trigger_template_error ("missing or misspelled comment closing tag '{$this->smarty->getRightDelimiter()}'");
389
        }
390
        $this->value = substr($this->data,$this->counter,$to-$this->counter);
391
        return false;
392
         }
393
    public function yy_r1_4()
394
    {
395
396
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
397
         }
398
    public function yy_r1_6()
399
    {
400
401
        $this->token = \Smarty\Parser\TemplateParser::TP_LITERALSTART;
402
        $this->yypushstate(self::LITERAL);
403
         }
404
    public function yy_r1_8()
405
    {
406
407
        $this->token = \Smarty\Parser\TemplateParser::TP_LITERALEND;
408
        $this->yypushstate(self::LITERAL);
409
         }
410
    public function yy_r1_10()
411
    {
412
413
        $this->yypushstate(self::TAG);
414
        return true;
415
         }
416
    public function yy_r1_12()
417
    {
418
419
       if (!isset($this->yy_global_text)) {
420
           $this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal/isS');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->replace('/(SMARTYldel)SMARTYal/isS') of type string is incompatible with the declared type null of property $yy_global_text.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
421
       }
422
       $to = $this->dataLength;
423
       preg_match($this->yy_global_text, $this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
424
       if (isset($match[0][1])) {
425
         $to = $match[0][1];
426
       }
427
       $this->value = substr($this->data,$this->counter,$to-$this->counter);
428
       $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
429
         }
430
431
     
432
    public function yylex2()
433
    {
434
        if (!isset($this->yy_global_pattern2)) {
435
            $this->yy_global_pattern2 = $this->replace("/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$]smarty\\.block\\.(child|parent)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/][0-9]*[a-zA-Z_]\\w*\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS");
436
        }
437
        if (!isset($this->dataLength)) {
438
            $this->dataLength = strlen($this->data);
439
        }
440
        if ($this->counter >=  $this->dataLength) {
441
            return false; // end of input
442
        }
443
        
444
        do {
445
            if (preg_match($this->yy_global_pattern2,$this->data, $yymatches, 0, $this->counter)) {
446
                if (!isset($yymatches[ 0 ][1])) {
447
                   $yymatches = preg_grep("/(.|\s)+/", $yymatches);
448
                } else {
449
                    $yymatches = array_filter($yymatches);
450
                }
451
                if (empty($yymatches)) {
452
                    throw new Exception('Error: lexing failed because a rule matched' .
453
                        ' an empty string.  Input "' . substr($this->data,
454
                        $this->counter, 5) . '... state TAG');
455
                }
456
                next($yymatches); // skip global match
457
                $this->token = key($yymatches); // token number
0 ignored issues
show
Documentation Bug introduced by
It seems like key($yymatches) can also be of type string. However, the property $token is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
458
                $this->value = current($yymatches); // token value
459
                $r = $this->{'yy_r2_' . $this->token}();
460
                if ($r === null) {
461
                    $this->counter += strlen($this->value);
462
                    $this->line += substr_count($this->value, "\n");
463
                    // accept this token
464
                    return true;
465
                } elseif ($r === true) {
466
                    // we have changed state
467
                    // process this token in the new state
468
                    return $this->yylex();
469
                } elseif ($r === false) {
470
                    $this->counter += strlen($this->value);
471
                    $this->line += substr_count($this->value, "\n");
472
                    if ($this->counter >=  $this->dataLength) {
473
                        return false; // end of input
474
                    }
475
                    // skip this token
476
                    continue;
477
                }            } else {
478
                throw new Exception('Unexpected input at line' . $this->line .
479
                    ': ' . $this->data[$this->counter]);
480
            }
481
            break;
482
        } while (true);
483
484
    } // end function
485
486
487
    const TAG = 2;
488
    public function yy_r2_1()
489
    {
490
491
        $this->token = \Smarty\Parser\TemplateParser::TP_LDELIF;
492
        $this->yybegin(self::TAGBODY);
493
        $this->taglineno = $this->line;
494
         }
495
    public function yy_r2_4()
496
    {
497
498
        $this->token = \Smarty\Parser\TemplateParser::TP_LDELFOR;
499
        $this->yybegin(self::TAGBODY);
500
        $this->taglineno = $this->line;
501
         }
502
    public function yy_r2_6()
503
    {
504
505
        $this->token = \Smarty\Parser\TemplateParser::TP_LDELFOREACH;
506
        $this->yybegin(self::TAGBODY);
507
        $this->taglineno = $this->line;
508
         }
509
    public function yy_r2_8()
510
    {
511
512
        $this->token = \Smarty\Parser\TemplateParser::TP_LDELSETFILTER;
513
        $this->yybegin(self::TAGBODY);
514
        $this->taglineno = $this->line;
515
         }
516
    public function yy_r2_10()
517
    {
518
519
        $this->yypopstate();
520
        $this->token = \Smarty\Parser\TemplateParser::TP_SIMPLETAG;
521
        $this->taglineno = $this->line;
522
         }
523
    public function yy_r2_13()
524
    {
525
526
         $this->yypopstate();
527
         $this->token = \Smarty\Parser\TemplateParser::TP_SMARTYBLOCKCHILDPARENT;
528
         $this->taglineno = $this->line;
529
         }
530
    public function yy_r2_16()
531
    {
532
533
        $this->yypopstate();
534
        $this->token = \Smarty\Parser\TemplateParser::TP_CLOSETAG;
535
        $this->taglineno = $this->line;
536
         }
537
    public function yy_r2_18()
538
    {
539
540
        if ($this->_yy_stack[count($this->_yy_stack)-1] === self::TEXT) {
541
            $this->yypopstate();
542
            $this->token = \Smarty\Parser\TemplateParser::TP_SIMPELOUTPUT;
543
            $this->taglineno = $this->line;
544
        } else {
545
            $this->value = $this->smarty->getLeftDelimiter();
546
            $this->token = \Smarty\Parser\TemplateParser::TP_LDEL;
547
            $this->yybegin(self::TAGBODY);
548
            $this->taglineno = $this->line;
549
        }
550
         }
551
    public function yy_r2_21()
552
    {
553
554
        $this->token = \Smarty\Parser\TemplateParser::TP_LDELSLASH;
555
        $this->yybegin(self::TAGBODY);
556
        $this->taglineno = $this->line;
557
         }
558
    public function yy_r2_23()
559
    {
560
561
        $this->token = \Smarty\Parser\TemplateParser::TP_LDEL;
562
        $this->yybegin(self::TAGBODY);
563
        $this->taglineno = $this->line;
564
         }
565
566
     
567
    public function yylex3()
568
    {
569
        if (!isset($this->yy_global_pattern3)) {
570
            $this->yy_global_pattern3 = $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+(not\\s+)?in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
571
        }
572
        if (!isset($this->dataLength)) {
573
            $this->dataLength = strlen($this->data);
574
        }
575
        if ($this->counter >=  $this->dataLength) {
576
            return false; // end of input
577
        }
578
        
579
        do {
580
            if (preg_match($this->yy_global_pattern3,$this->data, $yymatches, 0, $this->counter)) {
581
                if (!isset($yymatches[ 0 ][1])) {
582
                   $yymatches = preg_grep("/(.|\s)+/", $yymatches);
583
                } else {
584
                    $yymatches = array_filter($yymatches);
585
                }
586
                if (empty($yymatches)) {
587
                    throw new Exception('Error: lexing failed because a rule matched' .
588
                        ' an empty string.  Input "' . substr($this->data,
589
                        $this->counter, 5) . '... state TAGBODY');
590
                }
591
                next($yymatches); // skip global match
592
                $this->token = key($yymatches); // token number
0 ignored issues
show
Documentation Bug introduced by
It seems like key($yymatches) can also be of type string. However, the property $token is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
593
                $this->value = current($yymatches); // token value
594
                $r = $this->{'yy_r3_' . $this->token}();
595
                if ($r === null) {
596
                    $this->counter += strlen($this->value);
597
                    $this->line += substr_count($this->value, "\n");
598
                    // accept this token
599
                    return true;
600
                } elseif ($r === true) {
601
                    // we have changed state
602
                    // process this token in the new state
603
                    return $this->yylex();
604
                } elseif ($r === false) {
605
                    $this->counter += strlen($this->value);
606
                    $this->line += substr_count($this->value, "\n");
607
                    if ($this->counter >=  $this->dataLength) {
608
                        return false; // end of input
609
                    }
610
                    // skip this token
611
                    continue;
612
                }            } else {
613
                throw new Exception('Unexpected input at line' . $this->line .
614
                    ': ' . $this->data[$this->counter]);
615
            }
616
            break;
617
        } while (true);
618
619
    } // end function
620
621
622
    const TAGBODY = 3;
623
    public function yy_r3_1()
624
    {
625
626
        $this->token = \Smarty\Parser\TemplateParser::TP_RDEL;
627
        $this->yypopstate();
628
         }
629
    public function yy_r3_2()
630
    {
631
632
        $this->yypushstate(self::TAG);
633
        return true;
634
         }
635
    public function yy_r3_4()
636
    {
637
638
        $this->token = \Smarty\Parser\TemplateParser::TP_QUOTE;
639
        $this->yypushstate(self::DOUBLEQUOTEDSTRING);
640
        $this->compiler->enterDoubleQuote();
641
         }
642
    public function yy_r3_5()
643
    {
644
645
        $this->token = \Smarty\Parser\TemplateParser::TP_SINGLEQUOTESTRING;
646
         }
647
    public function yy_r3_6()
648
    {
649
650
        $this->token = \Smarty\Parser\TemplateParser::TP_DOLLARID;
651
         }
652
    public function yy_r3_7()
653
    {
654
655
        $this->token = \Smarty\Parser\TemplateParser::TP_DOLLAR;
656
         }
657
    public function yy_r3_8()
658
    {
659
660
        $this->token = \Smarty\Parser\TemplateParser::TP_ISIN;
661
         }
662
    public function yy_r3_10()
663
    {
664
665
        $this->token = \Smarty\Parser\TemplateParser::TP_AS;
666
         }
667
    public function yy_r3_11()
668
    {
669
670
        $this->token = \Smarty\Parser\TemplateParser::TP_TO;
671
         }
672
    public function yy_r3_12()
673
    {
674
675
        $this->token = \Smarty\Parser\TemplateParser::TP_STEP;
676
         }
677
    public function yy_r3_13()
678
    {
679
680
        $this->token = \Smarty\Parser\TemplateParser::TP_INSTANCEOF;
681
         }
682
    public function yy_r3_14()
683
    {
684
685
        $this->token = \Smarty\Parser\TemplateParser::TP_LOGOP;
686
         }
687
    public function yy_r3_16()
688
    {
689
690
        $this->token = \Smarty\Parser\TemplateParser::TP_SLOGOP;
691
         }
692
    public function yy_r3_18()
693
    {
694
695
        $this->token = \Smarty\Parser\TemplateParser::TP_TLOGOP;
696
         }
697
    public function yy_r3_21()
698
    {
699
700
        $this->token = \Smarty\Parser\TemplateParser::TP_SINGLECOND;
701
         }
702
    public function yy_r3_24()
703
    {
704
705
        $this->token = \Smarty\Parser\TemplateParser::TP_NOT;
706
         }
707
    public function yy_r3_25()
708
    {
709
710
        $this->token = \Smarty\Parser\TemplateParser::TP_TYPECAST;
711
         }
712
    public function yy_r3_29()
713
    {
714
715
        $this->token = \Smarty\Parser\TemplateParser::TP_OPENP;
716
         }
717
    public function yy_r3_30()
718
    {
719
720
        $this->token = \Smarty\Parser\TemplateParser::TP_CLOSEP;
721
         }
722
    public function yy_r3_31()
723
    {
724
725
        $this->token = \Smarty\Parser\TemplateParser::TP_OPENB;
726
         }
727
    public function yy_r3_32()
728
    {
729
730
        $this->token = \Smarty\Parser\TemplateParser::TP_CLOSEB;
731
         }
732
    public function yy_r3_33()
733
    {
734
735
        $this->token = \Smarty\Parser\TemplateParser::TP_PTR;
736
         }
737
    public function yy_r3_34()
738
    {
739
740
        $this->token = \Smarty\Parser\TemplateParser::TP_APTR;
741
         }
742
    public function yy_r3_35()
743
    {
744
745
        $this->token = \Smarty\Parser\TemplateParser::TP_EQUAL;
746
         }
747
    public function yy_r3_36()
748
    {
749
750
        $this->token = \Smarty\Parser\TemplateParser::TP_INCDEC;
751
         }
752
    public function yy_r3_38()
753
    {
754
755
        $this->token = \Smarty\Parser\TemplateParser::TP_UNIMATH;
756
         }
757
    public function yy_r3_40()
758
    {
759
760
        $this->token = \Smarty\Parser\TemplateParser::TP_MATH;
761
         }
762
    public function yy_r3_42()
763
    {
764
765
        $this->token = \Smarty\Parser\TemplateParser::TP_AT;
766
         }
767
    public function yy_r3_43()
768
    {
769
770
        $this->token = \Smarty\Parser\TemplateParser::TP_ARRAYOPEN;
771
         }
772
    public function yy_r3_44()
773
    {
774
775
        $this->token = \Smarty\Parser\TemplateParser::TP_HATCH;
776
         }
777
    public function yy_r3_45()
778
    {
779
780
        // resolve conflicts with shorttag and right_delimiter starting with '='
781
        if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()) {
782
            preg_match('/\s+/',$this->value,$match);
783
            $this->value = $match[0];
784
            $this->token = \Smarty\Parser\TemplateParser::TP_SPACE;
785
        } else {
786
            $this->token = \Smarty\Parser\TemplateParser::TP_ATTR;
787
        }
788
         }
789
    public function yy_r3_46()
790
    {
791
792
        $this->token = \Smarty\Parser\TemplateParser::TP_NAMESPACE;
793
         }
794
    public function yy_r3_49()
795
    {
796
797
        $this->token = \Smarty\Parser\TemplateParser::TP_ID;
798
         }
799
    public function yy_r3_50()
800
    {
801
802
        $this->token = \Smarty\Parser\TemplateParser::TP_INTEGER;
803
         }
804
    public function yy_r3_51()
805
    {
806
807
        $this->token = \Smarty\Parser\TemplateParser::TP_BACKTICK;
808
        $this->yypopstate();
809
         }
810
    public function yy_r3_52()
811
    {
812
813
        $this->token = \Smarty\Parser\TemplateParser::TP_VERT;
814
         }
815
    public function yy_r3_53()
816
    {
817
818
        $this->token = \Smarty\Parser\TemplateParser::TP_DOT;
819
         }
820
    public function yy_r3_54()
821
    {
822
823
        $this->token = \Smarty\Parser\TemplateParser::TP_COMMA;
824
         }
825
    public function yy_r3_55()
826
    {
827
828
        $this->token = \Smarty\Parser\TemplateParser::TP_SEMICOLON;
829
         }
830
    public function yy_r3_56()
831
    {
832
833
        $this->token = \Smarty\Parser\TemplateParser::TP_DOUBLECOLON;
834
         }
835
    public function yy_r3_57()
836
    {
837
838
        $this->token = \Smarty\Parser\TemplateParser::TP_COLON;
839
         }
840
    public function yy_r3_58()
841
    {
842
843
        $this->token = \Smarty\Parser\TemplateParser::TP_QMARK;
844
         }
845
    public function yy_r3_59()
846
    {
847
848
        $this->token = \Smarty\Parser\TemplateParser::TP_HEX;
849
         }
850
    public function yy_r3_60()
851
    {
852
853
        $this->token = \Smarty\Parser\TemplateParser::TP_SPACE;
854
         }
855
    public function yy_r3_61()
856
    {
857
858
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
859
         }
860
861
862
     
863
    public function yylex4()
864
    {
865
        if (!isset($this->yy_global_pattern4)) {
866
            $this->yy_global_pattern4 = $this->replace("/\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G([\S\s])/isS");
867
        }
868
        if (!isset($this->dataLength)) {
869
            $this->dataLength = strlen($this->data);
870
        }
871
        if ($this->counter >=  $this->dataLength) {
872
            return false; // end of input
873
        }
874
        
875
        do {
876
            if (preg_match($this->yy_global_pattern4,$this->data, $yymatches, 0, $this->counter)) {
877
                if (!isset($yymatches[ 0 ][1])) {
878
                   $yymatches = preg_grep("/(.|\s)+/", $yymatches);
879
                } else {
880
                    $yymatches = array_filter($yymatches);
881
                }
882
                if (empty($yymatches)) {
883
                    throw new Exception('Error: lexing failed because a rule matched' .
884
                        ' an empty string.  Input "' . substr($this->data,
885
                        $this->counter, 5) . '... state LITERAL');
886
                }
887
                next($yymatches); // skip global match
888
                $this->token = key($yymatches); // token number
0 ignored issues
show
Documentation Bug introduced by
It seems like key($yymatches) can also be of type string. However, the property $token is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
889
                $this->value = current($yymatches); // token value
890
                $r = $this->{'yy_r4_' . $this->token}();
891
                if ($r === null) {
892
                    $this->counter += strlen($this->value);
893
                    $this->line += substr_count($this->value, "\n");
894
                    // accept this token
895
                    return true;
896
                } elseif ($r === true) {
897
                    // we have changed state
898
                    // process this token in the new state
899
                    return $this->yylex();
900
                } elseif ($r === false) {
901
                    $this->counter += strlen($this->value);
902
                    $this->line += substr_count($this->value, "\n");
903
                    if ($this->counter >=  $this->dataLength) {
904
                        return false; // end of input
905
                    }
906
                    // skip this token
907
                    continue;
908
                }            } else {
909
                throw new Exception('Unexpected input at line' . $this->line .
910
                    ': ' . $this->data[$this->counter]);
911
            }
912
            break;
913
        } while (true);
914
915
    } // end function
916
917
918
    const LITERAL = 4;
919
    public function yy_r4_1()
920
    {
921
922
        $this->literal_cnt++;
923
        $this->token = \Smarty\Parser\TemplateParser::TP_LITERAL;
924
         }
925
    public function yy_r4_3()
926
    {
927
928
        if ($this->literal_cnt) {
929
             $this->literal_cnt--;
930
            $this->token = \Smarty\Parser\TemplateParser::TP_LITERAL;
931
        } else {
932
            $this->token = \Smarty\Parser\TemplateParser::TP_LITERALEND;
933
            $this->yypopstate();
934
        }
935
         }
936
    public function yy_r4_5()
937
    {
938
939
       if (!isset($this->yy_global_literal)) {
940
           $this->yy_global_literal = $this->replace('/(SMARTYldel)SMARTYal[\/]?literalSMARTYrdel/isS');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->replace('/(SMARTY...literalSMARTYrdel/isS') of type string is incompatible with the declared type null of property $yy_global_literal.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
941
       }
942
       $to = $this->dataLength;
943
       preg_match($this->yy_global_literal, $this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
944
       if (isset($match[0][1])) {
945
         $to = $match[0][1];
946
       } else {
947
          $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
948
       }
949
       $this->value = substr($this->data,$this->counter,$to-$this->counter);
950
       $this->token = \Smarty\Parser\TemplateParser::TP_LITERAL;
951
         }
952
953
     
954
    public function yylex5()
955
    {
956
        if (!isset($this->yy_global_pattern5)) {
957
            $this->yy_global_pattern5 = $this->replace("/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\"SMARTYliteral)))|\G([\S\s])/isS");
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->replace('/\G((SMA...ral)))|\G([\S\s])/isS') of type string is incompatible with the declared type null of property $yy_global_pattern5.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
958
        }
959
        if (!isset($this->dataLength)) {
960
            $this->dataLength = strlen($this->data);
961
        }
962
        if ($this->counter >=  $this->dataLength) {
963
            return false; // end of input
964
        }
965
        
966
        do {
967
            if (preg_match($this->yy_global_pattern5,$this->data, $yymatches, 0, $this->counter)) {
968
                if (!isset($yymatches[ 0 ][1])) {
969
                   $yymatches = preg_grep("/(.|\s)+/", $yymatches);
970
                } else {
971
                    $yymatches = array_filter($yymatches);
972
                }
973
                if (empty($yymatches)) {
974
                    throw new Exception('Error: lexing failed because a rule matched' .
975
                        ' an empty string.  Input "' . substr($this->data,
976
                        $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
977
                }
978
                next($yymatches); // skip global match
979
                $this->token = key($yymatches); // token number
0 ignored issues
show
Documentation Bug introduced by
It seems like key($yymatches) can also be of type string. However, the property $token is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
980
                $this->value = current($yymatches); // token value
981
                $r = $this->{'yy_r5_' . $this->token}();
982
                if ($r === null) {
983
                    $this->counter += strlen($this->value);
984
                    $this->line += substr_count($this->value, "\n");
985
                    // accept this token
986
                    return true;
987
                } elseif ($r === true) {
988
                    // we have changed state
989
                    // process this token in the new state
990
                    return $this->yylex();
991
                } elseif ($r === false) {
992
                    $this->counter += strlen($this->value);
993
                    $this->line += substr_count($this->value, "\n");
994
                    if ($this->counter >=  $this->dataLength) {
995
                        return false; // end of input
996
                    }
997
                    // skip this token
998
                    continue;
999
                }            } else {
1000
                throw new Exception('Unexpected input at line' . $this->line .
1001
                    ': ' . $this->data[$this->counter]);
1002
            }
1003
            break;
1004
        } while (true);
1005
1006
    } // end function
1007
1008
1009
    const DOUBLEQUOTEDSTRING = 5;
1010
    public function yy_r5_1()
1011
    {
1012
1013
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
1014
         }
1015
    public function yy_r5_3()
1016
    {
1017
1018
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
1019
         }
1020
    public function yy_r5_5()
1021
    {
1022
1023
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
1024
         }
1025
    public function yy_r5_7()
1026
    {
1027
1028
        $this->yypushstate(self::TAG);
1029
        return true;
1030
         }
1031
    public function yy_r5_9()
1032
    {
1033
1034
        $this->yypushstate(self::TAG);
1035
        return true;
1036
         }
1037
    public function yy_r5_11()
1038
    {
1039
1040
        $this->token = \Smarty\Parser\TemplateParser::TP_LDEL;
1041
        $this->taglineno = $this->line;
1042
        $this->yypushstate(self::TAGBODY);
1043
         }
1044
    public function yy_r5_13()
1045
    {
1046
1047
        $this->token = \Smarty\Parser\TemplateParser::TP_QUOTE;
1048
        $this->yypopstate();
1049
         }
1050
    public function yy_r5_14()
1051
    {
1052
1053
        $this->token = \Smarty\Parser\TemplateParser::TP_BACKTICK;
1054
        $this->value = substr($this->value,0,-1);
1055
        $this->yypushstate(self::TAGBODY);
1056
        $this->taglineno = $this->line;
1057
         }
1058
    public function yy_r5_15()
1059
    {
1060
1061
        $this->token = \Smarty\Parser\TemplateParser::TP_DOLLARID;
1062
         }
1063
    public function yy_r5_16()
1064
    {
1065
1066
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
1067
         }
1068
    public function yy_r5_17()
1069
    {
1070
1071
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
1072
         }
1073
    public function yy_r5_22()
1074
    {
1075
1076
        $to = $this->dataLength;
1077
        $this->value = substr($this->data,$this->counter,$to-$this->counter);
1078
        $this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
1079
         }
1080
1081
  }
1082
1083