From 25424ea499a1adcdd4b451bbdd5a2067920554e2 Mon Sep 17 00:00:00 2001
From: uwetews <uwe.tews@googlemail.com>
Date: Fri, 31 Aug 2018 01:59:58 +0200
Subject: [PATCH] Make generated lexer and parser compatible with PSR-2 code
 style https://github.com/smarty-php/smarty/pull/483

---
 LexerGenerator/Parser.php       |  4 ++--
 LexerGenerator/Regex/Parser.php |  2 +-
 ParserGenerator/Data.php        | 14 +++++++-------
 3 files changed, 10 insertions(+), 10 deletions(-)

--- a/LexerGenerator/Parser.php
+++ b/LexerGenerator/Parser.php
@@ -499,7 +499,7 @@
 ');
         }
         foreach ($rules as $i => $rule) {
-            fwrite($this->out, '    function yy_r' . $this -> _outRuleIndex . '_' . $ruleMap[$i] . '()
+            fwrite($this->out, '    public function yy_r' . $this -> _outRuleIndex . '_' . $ruleMap[$i] . '()
     {
 ' . $rule['code'] .
 '    }
@@ -605,7 +605,7 @@
 **  self::$yy_default       Default action for each state.
 */
     const YY_SZ_ACTTAB = 91;
-static public $yy_action = array(
+public static $yy_action = array(
  /*     0 */    25,   50,   49,   31,   49,   54,   53,   54,   53,   35,
  /*    10 */    11,   49,   18,   22,   54,   53,   14,   59,   51,   28,
  /*    20 */    55,   57,   58,   59,   47,    1,   55,   57,   32,   15,
--- a/LexerGenerator/Regex/Parser.php
+++ b/LexerGenerator/Regex/Parser.php
@@ -221,7 +221,7 @@
 **  self::$yy_default       Default action for each state.
 */
     const YY_SZ_ACTTAB = 354;
-static public $yy_action = array(
+public static $yy_action = array(
  /*     0 */   229,   45,   15,   23,  104,  106,  107,  109,  108,  118,
  /*    10 */   119,  129,  128,  130,   36,   15,   23,  104,  106,  107,
  /*    20 */   109,  108,  118,  119,  129,  128,  130,   39,   15,   23,
--- a/ParserGenerator/Data.php
+++ b/ParserGenerator/Data.php
@@ -1246,7 +1246,7 @@
 
         fprintf($out, "    const YY_SZ_ACTTAB = %d;\n", $pActtab->nAction);
         $lineno++;
-        fwrite($out, "static public \$yy_action = array(\n");
+        fwrite($out, "public static \$yy_action = array(\n");
         $lineno++;
         $n = $pActtab->nAction;
         for ($i = $j = 0; $i < $n; $i++) {
@@ -1271,7 +1271,7 @@
 
         /* Output the yy_lookahead table */
 
-        fwrite($out, "    static public \$yy_lookahead = array(\n");
+        fwrite($out, "    public static \$yy_lookahead = array(\n");
         $lineno++;
         for ($i = $j = 0; $i < $n; $i++) {
             $la = $pActtab->aAction[$i]['lookahead'];
@@ -1303,7 +1303,7 @@
         }
         fprintf($out, "    const YY_SHIFT_MAX = %d;\n", $n - 1);
         $lineno++;
-        fwrite($out, "    static public \$yy_shift_ofst = array(\n");
+        fwrite($out, "    public static \$yy_shift_ofst = array(\n");
         $lineno++;
         for ($i = $j = 0; $i < $n; $i++) {
             $stp = $this->sorted[$i];
@@ -1337,7 +1337,7 @@
         }
         fprintf($out, "    const YY_REDUCE_MAX = %d;\n", $n - 1);
         $lineno++;
-        fwrite($out, "    static public \$yy_reduce_ofst = array(\n");
+        fwrite($out, "    public static \$yy_reduce_ofst = array(\n");
         $lineno++;
         for ($i = $j = 0; $i < $n; $i++) {
             $stp = $this->sorted[$i];
@@ -1363,7 +1363,7 @@
 
         /* Output the expected tokens table */
 
-        fwrite($out, "    static public \$yyExpectedTokens = array(\n");
+        fwrite($out, "    public static \$yyExpectedTokens = array(\n");
         $lineno++;
         for ($i = 0; $i < $this->nstate; $i++) {
             $stp = $this->sorted[$i];
@@ -1384,7 +1384,7 @@
 
         /* Output the default action table */
 
-        fwrite($out, "    static public \$yy_default = array(\n");
+        fwrite($out, "    public static \$yy_default = array(\n");
         $lineno++;
         $n = $this->nstate;
         for ($i = $j = 0; $i < $n; $i++) {
@@ -1655,7 +1655,7 @@
         /* Generate code to do the reduce action */
         if ($rp->code) {
             $this->tplt_linedir($out, $rp->line, $this->filename);
-            fwrite($out, "    function yy_r$rp->index()".'{' . $rp->code);
+            fwrite($out, "    public function yy_r$rp->index()".'{' . $rp->code);
             $linecnt += count(explode("\n", $rp->code)) - 1;
             $lineno += 3 + $linecnt;
             fwrite($out, "    }\n");
