Passed
Pull Request — master (#3)
by Chris
04:26
created
php/hamle/Tag/Control.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
    */
48 48
   function __construct($tag, $parentTag = null) {
49 49
     parent::__construct();
50
-    $this->o = "\$o" . self::$instCount++;
50
+    $this->o = "\$o".self::$instCount++;
51 51
     $this->type = strtolower($tag);
52 52
     $this->var = "";
53 53
     if ($parentTag && $this->type == "else") {
54
-      if($parentTag instanceof H\Tag) {
54
+      if ($parentTag instanceof H\Tag) {
55 55
         $elseTag = $parentTag->tags[count($parentTag->tags) - 1];
56
-        if($elseTag instanceof H\Tag\Control &&
56
+        if ($elseTag instanceof H\Tag\Control &&
57 57
             in_array($elseTag->type, array('with', 'if'))
58 58
         ) {
59 59
           $elseTag->else = true;
@@ -67,17 +67,17 @@  discard block
 block discarded – undo
67 67
   }
68 68
 
69 69
   function renderStTag() {
70
-    $out = "<" . "?php ";
70
+    $out = "<"."?php ";
71 71
     $scopeName = "";
72
-    if($this->type === 'if') {
72
+    if ($this->type === 'if') {
73 73
       $hsvcomp = new H\Text\Comparison($this->var);
74
-      $out .= "if(" . $hsvcomp->toPHP() . ") {";
74
+      $out .= "if(".$hsvcomp->toPHP().") {";
75 75
       return $out."\n?>";
76
-    } elseif($this->type === 'else') {
76
+    } elseif ($this->type === 'else') {
77 77
       $out .= "/* else */";
78 78
       return $out."\n?>";
79 79
     }
80
-    if($this->var) {
80
+    if ($this->var) {
81 81
       if (preg_match('/ as ([a-zA-Z]+)$/', $this->var, $m)) {
82 82
         $scopeName = $m[1];
83 83
         $lookup = substr($this->var, 0, strlen($this->var) - strlen($m[0]));
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
     switch ($this->type) {
89 89
       case "each":
90 90
         if ($this->var)
91
-          $out .= "foreach(" . $hsv->toPHP() . " as {$this->o}) { \n";
91
+          $out .= "foreach(".$hsv->toPHP()." as {$this->o}) { \n";
92 92
         else
93 93
           $out .= "foreach(Hamle\\Scope::get() as {$this->o}) { \n";
94 94
         $out .= "Hamle\\Scope::add({$this->o}); ";
95 95
         break;
96 96
       case "with":
97 97
         if ($scopeName)
98
-          $out .= "Hamle\\Scope::add(" . $hsv->toPHP() . ", \"$scopeName\");\n;";
98
+          $out .= "Hamle\\Scope::add(".$hsv->toPHP().", \"$scopeName\");\n;";
99 99
         else {
100
-          $out .= "if(({$this->o} = " . $hsv->toPHP() . ") && " .
100
+          $out .= "if(({$this->o} = ".$hsv->toPHP().") && ".
101 101
               "{$this->o}->valid()) {\n";
102 102
           $out .= "Hamle\\Scope::add({$this->o});\n;";
103 103
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         $fn = $file[0] === '#' ? 'includeFragment' : 'includeFile';
108 108
         $out .= "echo Hamle\\Run::$fn({$hsv->toPHP()});";
109 109
     }
110
-    return $out . "\n?>";
110
+    return $out."\n?>";
111 111
   }
112 112
 
113 113
   /**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   }
119 119
 
120 120
   function renderEnTag() {
121
-    $out = '<' . '?php ';
121
+    $out = '<'.'?php ';
122 122
     switch ($this->type) {
123 123
       case "each";
124 124
         $out .= 'Hamle\\Scope::done(); ';
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         break;
142 142
     }
143 143
     if ($this->else) $out .= "else{";
144
-    return $out . "\n?>";
144
+    return $out."\n?>";
145 145
   }
146 146
 
147 147
   function render($indent = 0, $minify = false) {
Please login to merge, or discard this patch.
Braces   +23 added lines, -15 removed lines patch added patch discarded remove patch
@@ -82,21 +82,23 @@  discard block
 block discarded – undo
82 82
         $scopeName = $m[1];
83 83
         $lookup = substr($this->var, 0, strlen($this->var) - strlen($m[0]));
84 84
         $hsv = new H\Text(trim($lookup), H\Text::TOKEN_CONTROL);
85
-      } else
86
-        $hsv = new H\Text($this->var, H\Text::TOKEN_CONTROL);
85
+      } else {
86
+              $hsv = new H\Text($this->var, H\Text::TOKEN_CONTROL);
87
+      }
87 88
     }
88 89
     switch ($this->type) {
89 90
       case "each":
90
-        if ($this->var)
91
-          $out .= "foreach(" . $hsv->toPHP() . " as {$this->o}) { \n";
92
-        else
93
-          $out .= "foreach(Hamle\\Scope::get() as {$this->o}) { \n";
91
+        if ($this->var) {
92
+                  $out .= "foreach(" . $hsv->toPHP() . " as {$this->o}) { \n";
93
+        } else {
94
+                  $out .= "foreach(Hamle\\Scope::get() as {$this->o}) { \n";
95
+        }
94 96
         $out .= "Hamle\\Scope::add({$this->o}); ";
95 97
         break;
96 98
       case "with":
97
-        if ($scopeName)
98
-          $out .= "Hamle\\Scope::add(" . $hsv->toPHP() . ", \"$scopeName\");\n;";
99
-        else {
99
+        if ($scopeName) {
100
+                  $out .= "Hamle\\Scope::add(" . $hsv->toPHP() . ", \"$scopeName\");\n;";
101
+        } else {
100 102
           $out .= "if(({$this->o} = " . $hsv->toPHP() . ") && " .
101 103
               "{$this->o}->valid()) {\n";
102 104
           $out .= "Hamle\\Scope::add({$this->o});\n;";
@@ -123,8 +125,9 @@  discard block
 block discarded – undo
123 125
       case "each";
124 126
         $out .= 'Hamle\\Scope::done(); ';
125 127
         $out .= '}';
126
-        if (!$this->var)
127
-          $out .= "Hamle\\Scope::get()->rewind();\n";
128
+        if (!$this->var) {
129
+                  $out .= "Hamle\\Scope::get()->rewind();\n";
130
+        }
128 131
         break;
129 132
       case "if":
130 133
       case "else":
@@ -140,7 +143,9 @@  discard block
 block discarded – undo
140 143
         return "";
141 144
         break;
142 145
     }
143
-    if ($this->else) $out .= "else{";
146
+    if ($this->else) {
147
+      $out .= "else{";
148
+    }
144 149
     return $out . "\n?>";
145 150
   }
146 151
 
@@ -148,9 +153,12 @@  discard block
 block discarded – undo
148 153
     $ind = $minify ? '' : str_pad('', $indent);
149 154
     $oneliner = (!(count($this->content) > 1 || $this->tags));
150 155
     $out = $this->renderStTag();
151
-    if ($this->content) $out .= $this->renderContent($ind, $oneliner || $minify);
152
-    foreach ($this->tags as $tag)
153
-      $out .= $tag->render($indent, $minify);
156
+    if ($this->content) {
157
+      $out .= $this->renderContent($ind, $oneliner || $minify);
158
+    }
159
+    foreach ($this->tags as $tag) {
160
+          $out .= $tag->render($indent, $minify);
161
+    }
154 162
     $out .= $this->renderEnTag();
155 163
     return $out;
156 164
   }
Please login to merge, or discard this patch.
php/hamle/Grammar/Parser.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -301,14 +301,14 @@
 block discarded – undo
301 301
     private function peg_f1($i) { $return = array();
302 302
                                                   array_walk_recursive($i, function($a) use (&$return) { $return[] = $a; });
303 303
                                                   return $return;
304
-                                         }
304
+                                          }
305 305
     private function peg_f2($text) { return new \Seufert\Hamle\TextNode\StringLit(join('',$text)); }
306 306
     private function peg_f3($body) { return $body; }
307 307
     private function peg_f4($name) {
308 308
             return new \Seufert\Hamle\TextNode\ScopeId(null, null, new \Seufert\Hamle\TextNode\ModelParam($name)); }
309 309
     private function peg_f5($expr, $chain) { if(!$chain) return $expr;
310
-                           $top = array_pop($chain);
311
-                           while($chain) { $top = array_pop($chain)->withChain($top); } return $expr->withChain($top); }
310
+                            $top = array_pop($chain);
311
+                            while($chain) { $top = array_pop($chain)->withChain($top); } return $expr->withChain($top); }
312 312
     private function peg_f6($sub) { return $sub; }
313 313
     private function peg_f7($filter) { return $filter; }
314 314
     private function peg_f8($name) { return new \Seufert\Hamle\TextNode\ModelParam($name, null); }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     private $peg_currPos          = 0;
68 68
     private $peg_reportedPos      = 0;
69 69
     private $peg_cachedPos        = 0;
70
-    private $peg_cachedPosDetails = array('line' => 1, 'column' => 1, 'seenCR' => false );
70
+    private $peg_cachedPosDetails = array('line' => 1, 'column' => 1, 'seenCR' => false);
71 71
     private $peg_maxFailPos       = 0;
72 72
     private $peg_maxFailExpected  = array();
73 73
     private $peg_silentFails      = 0;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
       $this->peg_currPos          = 0;
79 79
       $this->peg_reportedPos      = 0;
80 80
       $this->peg_cachedPos        = 0;
81
-      $this->peg_cachedPosDetails = array('line' => 1, 'column' => 1, 'seenCR' => false );
81
+      $this->peg_cachedPosDetails = array('line' => 1, 'column' => 1, 'seenCR' => false);
82 82
       $this->peg_maxFailPos       = 0;
83 83
       $this->peg_maxFailExpected  = array();
84 84
       $this->peg_silentFails      = 0;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     private function expected($description) {
122 122
       throw $this->peg_buildException(
123 123
         null,
124
-        array(array("type" => "other", "description" => $description )),
124
+        array(array("type" => "other", "description" => $description)),
125 125
         $this->peg_reportedPos
126 126
       );
127 127
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
       if ($this->peg_cachedPos !== $pos) {
153 153
         if ($this->peg_cachedPos > $pos) {
154 154
           $this->peg_cachedPos = 0;
155
-          $this->peg_cachedPosDetails = array( "line" => 1, "column" => 1, "seenCR" => false );
155
+          $this->peg_cachedPosDetails = array("line" => 1, "column" => 1, "seenCR" => false);
156 156
         }
157 157
         $this->peg_advancePos($this->peg_cachedPosDetails, $this->peg_cachedPos, $pos);
158 158
         $this->peg_cachedPos = $pos;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
         $foundDesc = $found ? json_encode($found) : "end of input";
215 215
 
216
-        $message = "Expected " . $expectedDesc . " but " . $foundDesc . " found.";
216
+        $message = "Expected ".$expectedDesc." but ".$foundDesc." found.";
217 217
       }
218 218
 
219 219
       return new SyntaxError(
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
                                                   array_walk_recursive($i, function($a) use (&$return) { $return[] = $a; });
303 303
                                                   return $return;
304 304
                                          }
305
-    private function peg_f2($text) { return new \Seufert\Hamle\TextNode\StringLit(join('',$text)); }
305
+    private function peg_f2($text) { return new \Seufert\Hamle\TextNode\StringLit(join('', $text)); }
306 306
     private function peg_f3($body) { return $body; }
307 307
     private function peg_f4($name) {
308 308
             return new \Seufert\Hamle\TextNode\ScopeId(null, null, new \Seufert\Hamle\TextNode\ModelParam($name)); }
309
-    private function peg_f5($expr, $chain) { if(!$chain) return $expr;
309
+    private function peg_f5($expr, $chain) { if (!$chain) return $expr;
310 310
                            $top = array_pop($chain);
311
-                           while($chain) { $top = array_pop($chain)->withChain($top); } return $expr->withChain($top); }
311
+                           while ($chain) { $top = array_pop($chain)->withChain($top); } return $expr->withChain($top); }
312 312
     private function peg_f6($sub) { return $sub; }
313 313
     private function peg_f7($filter) { return $filter; }
314 314
     private function peg_f8($name) { return new \Seufert\Hamle\TextNode\ModelParam($name, null); }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     private function peg_f15($query) { return new \Seufert\Hamle\TextNode\Query($query); }
322 322
     private function peg_f16($id, $query) { return array_merge([['q'=>'type', 'id'=> $id]], $query); }
323 323
     private function peg_f17($query) { return array_merge([['q'=>'type', 'id'=> '*']], $query); }
324
-    private function peg_f18($rel, $sub) { return \Seufert\Hamle\TextNode\RelQuery::for($rel, $sub); }
324
+    private function peg_f18($rel, $sub) { return \Seufert\Hamle\TextNode\RelQuery::for ($rel, $sub); }
325 325
     private function peg_f19($id) { return ['q'=>'id', 'id'=> $id]; }
326 326
     private function peg_f20($id) { return ['q'=>'type', 'id'=> $id]; }
327 327
     private function peg_f21($id) { return ['q'=>'tag', 'id'=> $id]; }
@@ -335,19 +335,19 @@  discard block
 block discarded – undo
335 335
     private function peg_f29($func, $args) { return new \Seufert\Hamle\TextNode\FilterFunc($func, null, $args); }
336 336
     private function peg_f30($func) { return new \Seufert\Hamle\TextNode\FilterFunc($func); }
337 337
     private function peg_f31($arg) { return $arg; }
338
-    private function peg_f32($s, $n, $d) { return \Seufert\Hamle\TextNode\FloatLit((float)"$s$n.$d"); }
338
+    private function peg_f32($s, $n, $d) { return \Seufert\Hamle\TextNode\FloatLit((float) "$s$n.$d"); }
339 339
     private function peg_f33($parts) { return new \Seufert\Hamle\TextNode\StringLit($parts[1]); }
340 340
     private function peg_f34($chars) { return join('', $chars); }
341 341
     private function peg_f35($char_) { return $char_; }
342 342
     private function peg_f36($sequence) { return $sequence; }
343 343
     private function peg_f37($char) { return $char; }
344
-    private function peg_f38($n) { return (int)join('', $n); }
345
-    private function peg_f39($sign, $n) { return new \Seufert\Hamle\TextNode\IntLit((int)($sign.join('', $n))); }
346
-    private function peg_f40($name) { return join('',$name); }
344
+    private function peg_f38($n) { return (int) join('', $n); }
345
+    private function peg_f39($sign, $n) { return new \Seufert\Hamle\TextNode\IntLit((int) ($sign.join('', $n))); }
346
+    private function peg_f40($name) { return join('', $name); }
347 347
     private function peg_f41($p, $s) { return $p.join('', $s); }
348 348
     private function peg_f42($s) { return join('', $s); }
349 349
     private function peg_f43($c) { return $c; }
350
-    private function peg_f44($char_) { return str_replace(['n', 'r', 't'], ['\\n','\\r','\\t'], $char_); }
350
+    private function peg_f44($char_) { return str_replace(['n', 'r', 't'], ['\\n', '\\r', '\\t'], $char_); }
351 351
 
352 352
     private function peg_parseHtmlInput() {
353 353
 
@@ -2715,77 +2715,77 @@  discard block
 block discarded – undo
2715 2715
 
2716 2716
     $this->peg_FAILED = new \stdClass;
2717 2717
     $this->peg_c0 = "{";
2718
-    $this->peg_c1 = array( "type" => "literal", "value" => "{", "description" => "\"{\"" );
2718
+    $this->peg_c1 = array("type" => "literal", "value" => "{", "description" => "\"{\"");
2719 2719
     $this->peg_c2 = "}";
2720
-    $this->peg_c3 = array( "type" => "literal", "value" => "}", "description" => "\"}\"" );
2720
+    $this->peg_c3 = array("type" => "literal", "value" => "}", "description" => "\"}\"");
2721 2721
     $this->peg_c4 = "$";
2722
-    $this->peg_c5 = array( "type" => "literal", "value" => "$", "description" => "\"$\"" );
2722
+    $this->peg_c5 = array("type" => "literal", "value" => "$", "description" => "\"$\"");
2723 2723
     $this->peg_c6 = "|";
2724
-    $this->peg_c7 = array( "type" => "literal", "value" => "|", "description" => "\"|\"" );
2724
+    $this->peg_c7 = array("type" => "literal", "value" => "|", "description" => "\"|\"");
2725 2725
     $this->peg_c8 = "(";
2726
-    $this->peg_c9 = array( "type" => "literal", "value" => "(", "description" => "\"(\"" );
2726
+    $this->peg_c9 = array("type" => "literal", "value" => "(", "description" => "\"(\"");
2727 2727
     $this->peg_c10 = ")";
2728
-    $this->peg_c11 = array( "type" => "literal", "value" => ")", "description" => "\")\"" );
2728
+    $this->peg_c11 = array("type" => "literal", "value" => ")", "description" => "\")\"");
2729 2729
     $this->peg_c12 = "[";
2730
-    $this->peg_c13 = array( "type" => "literal", "value" => "[", "description" => "\"[\"" );
2730
+    $this->peg_c13 = array("type" => "literal", "value" => "[", "description" => "\"[\"");
2731 2731
     $this->peg_c14 = "]";
2732
-    $this->peg_c15 = array( "type" => "literal", "value" => "]", "description" => "\"]\"" );
2732
+    $this->peg_c15 = array("type" => "literal", "value" => "]", "description" => "\"]\"");
2733 2733
     $this->peg_c16 = "*";
2734
-    $this->peg_c17 = array( "type" => "literal", "value" => "*", "description" => "\"*\"" );
2734
+    $this->peg_c17 = array("type" => "literal", "value" => "*", "description" => "\"*\"");
2735 2735
     $this->peg_c18 = " ";
2736
-    $this->peg_c19 = array( "type" => "literal", "value" => " ", "description" => "\" \"" );
2736
+    $this->peg_c19 = array("type" => "literal", "value" => " ", "description" => "\" \"");
2737 2737
     $this->peg_c20 = "/^[><]/";
2738
-    $this->peg_c21 = array( "type" => "class", "value" => "[><]", "description" => "[><]" );
2738
+    $this->peg_c21 = array("type" => "class", "value" => "[><]", "description" => "[><]");
2739 2739
     $this->peg_c22 = "#";
2740
-    $this->peg_c23 = array( "type" => "literal", "value" => "#", "description" => "\"#\"" );
2740
+    $this->peg_c23 = array("type" => "literal", "value" => "#", "description" => "\"#\"");
2741 2741
     $this->peg_c24 = ",";
2742
-    $this->peg_c25 = array( "type" => "literal", "value" => ",", "description" => "\",\"" );
2742
+    $this->peg_c25 = array("type" => "literal", "value" => ",", "description" => "\",\"");
2743 2743
     $this->peg_c26 = ".";
2744
-    $this->peg_c27 = array( "type" => "literal", "value" => ".", "description" => "\".\"" );
2744
+    $this->peg_c27 = array("type" => "literal", "value" => ".", "description" => "\".\"");
2745 2745
     $this->peg_c28 = "^";
2746
-    $this->peg_c29 = array( "type" => "literal", "value" => "^", "description" => "\"^\"" );
2746
+    $this->peg_c29 = array("type" => "literal", "value" => "^", "description" => "\"^\"");
2747 2747
     $this->peg_c30 = "@";
2748
-    $this->peg_c31 = array( "type" => "literal", "value" => "@", "description" => "\"@\"" );
2748
+    $this->peg_c31 = array("type" => "literal", "value" => "@", "description" => "\"@\"");
2749 2749
     $this->peg_c32 = ":";
2750
-    $this->peg_c33 = array( "type" => "literal", "value" => ":", "description" => "\":\"" );
2750
+    $this->peg_c33 = array("type" => "literal", "value" => ":", "description" => "\":\"");
2751 2751
     $this->peg_c34 = "-";
2752
-    $this->peg_c35 = array( "type" => "literal", "value" => "-", "description" => "\"-\"" );
2752
+    $this->peg_c35 = array("type" => "literal", "value" => "-", "description" => "\"-\"");
2753 2753
     $this->peg_c36 = ">";
2754
-    $this->peg_c37 = array( "type" => "literal", "value" => ">", "description" => "\">\"" );
2754
+    $this->peg_c37 = array("type" => "literal", "value" => ">", "description" => "\">\"");
2755 2755
     $this->peg_c38 = "!";
2756
-    $this->peg_c39 = array( "type" => "literal", "value" => "!", "description" => "\"!\"" );
2756
+    $this->peg_c39 = array("type" => "literal", "value" => "!", "description" => "\"!\"");
2757 2757
     $this->peg_c40 = "/^[0-9]/";
2758
-    $this->peg_c41 = array( "type" => "class", "value" => "[0-9]", "description" => "[0-9]" );
2759
-    $this->peg_c42 = array("type" => "other", "description" => "string" );
2758
+    $this->peg_c41 = array("type" => "class", "value" => "[0-9]", "description" => "[0-9]");
2759
+    $this->peg_c42 = array("type" => "other", "description" => "string");
2760 2760
     $this->peg_c43 = "\"";
2761
-    $this->peg_c44 = array( "type" => "literal", "value" => "\"", "description" => "\"\\\"\"" );
2761
+    $this->peg_c44 = array("type" => "literal", "value" => "\"", "description" => "\"\\\"\"");
2762 2762
     $this->peg_c45 = "'";
2763
-    $this->peg_c46 = array( "type" => "literal", "value" => "'", "description" => "\"'\"" );
2763
+    $this->peg_c46 = array("type" => "literal", "value" => "'", "description" => "\"'\"");
2764 2764
     $this->peg_c47 = "\\";
2765
-    $this->peg_c48 = array( "type" => "literal", "value" => "\\", "description" => "\"\\\\\"" );
2766
-    $this->peg_c49 = array("type" => "any", "description" => "any character" );
2765
+    $this->peg_c48 = array("type" => "literal", "value" => "\\", "description" => "\"\\\\\"");
2766
+    $this->peg_c49 = array("type" => "any", "description" => "any character");
2767 2767
     $this->peg_c50 = "/^[a-zA-Z_]/";
2768
-    $this->peg_c51 = array( "type" => "class", "value" => "[a-zA-Z_]", "description" => "[a-zA-Z_]" );
2768
+    $this->peg_c51 = array("type" => "class", "value" => "[a-zA-Z_]", "description" => "[a-zA-Z_]");
2769 2769
     $this->peg_c52 = "/^[a-zA-Z_-]/";
2770
-    $this->peg_c53 = array( "type" => "class", "value" => "[a-zA-Z_-]", "description" => "[a-zA-Z_-]" );
2770
+    $this->peg_c53 = array("type" => "class", "value" => "[a-zA-Z_-]", "description" => "[a-zA-Z_-]");
2771 2771
     $this->peg_c54 = "/^[0-9a-zA-Z_-]/";
2772
-    $this->peg_c55 = array( "type" => "class", "value" => "[0-9a-zA-Z_-]", "description" => "[0-9a-zA-Z_-]" );
2772
+    $this->peg_c55 = array("type" => "class", "value" => "[0-9a-zA-Z_-]", "description" => "[0-9a-zA-Z_-]");
2773 2773
     $this->peg_c56 = "/^[^{\\\$]/";
2774
-    $this->peg_c57 = array( "type" => "class", "value" => "[{\$]", "description" => "[{\$]" );
2774
+    $this->peg_c57 = array("type" => "class", "value" => "[{\$]", "description" => "[{\$]");
2775 2775
     $this->peg_c58 = "/^[a-z]/";
2776
-    $this->peg_c59 = array( "type" => "class", "value" => "[a-z]", "description" => "[a-z]" );
2776
+    $this->peg_c59 = array("type" => "class", "value" => "[a-z]", "description" => "[a-z]");
2777 2777
     $this->peg_c60 = "/^[^{]/";
2778
-    $this->peg_c61 = array( "type" => "class", "value" => "[{]", "description" => "[{]" );
2778
+    $this->peg_c61 = array("type" => "class", "value" => "[{]", "description" => "[{]");
2779 2779
     $this->peg_c62 = "/^[\\n\\r\\x{2028}\\x{2029}]/";
2780
-    $this->peg_c63 = array( "type" => "class", "value" => "[\n\r\x{2028}\x{2029}]", "description" => "[\n\r\x{2028}\x{2029}]" );
2780
+    $this->peg_c63 = array("type" => "class", "value" => "[\n\r\x{2028}\x{2029}]", "description" => "[\n\r\x{2028}\x{2029}]");
2781 2781
     $this->peg_c64 = "/^['\"\\\\bfnrtv]/";
2782
-    $this->peg_c65 = array( "type" => "class", "value" => "['\"\\bfnrtv]", "description" => "['\"\\bfnrtv]" );
2782
+    $this->peg_c65 = array("type" => "class", "value" => "['\"\\bfnrtv]", "description" => "['\"\\bfnrtv]");
2783 2783
 
2784
-    $peg_startRuleFunctions = array( 'HtmlInput' => array($this, "peg_parseHtmlInput"), 'CodeInput' => array($this, "peg_parseCodeInput"), 'ControlInput' => array($this, "peg_parseControlInput") );
2784
+    $peg_startRuleFunctions = array('HtmlInput' => array($this, "peg_parseHtmlInput"), 'CodeInput' => array($this, "peg_parseCodeInput"), 'ControlInput' => array($this, "peg_parseControlInput"));
2785 2785
     $peg_startRuleFunction  = array($this, "peg_parseHtmlInput");
2786 2786
     if (isset($options["startRule"])) {
2787 2787
       if (!(isset($peg_startRuleFunctions[$options["startRule"]]))) {
2788
-        throw new \Exception("Can't start parsing from rule \"" + $options["startRule"] + "\".");
2788
+        throw new \Exception("Can't start parsing from rule \"" +$options["startRule"] + "\".");
2789 2789
       }
2790 2790
 
2791 2791
       $peg_startRuleFunction = $peg_startRuleFunctions[$options["startRule"]];
@@ -2799,7 +2799,7 @@  discard block
 block discarded – undo
2799 2799
       return $peg_result;
2800 2800
     } else {
2801 2801
       if ($peg_result !== $this->peg_FAILED && $this->peg_currPos < $this->input_length) {
2802
-        $this->peg_fail(array("type" => "end", "description" => "end of input" ));
2802
+        $this->peg_fail(array("type" => "end", "description" => "end of input"));
2803 2803
       }
2804 2804
 
2805 2805
       $exception = $this->peg_buildException(null, $this->peg_maxFailExpected, $this->peg_maxFailPos);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -306,7 +306,9 @@
 block discarded – undo
306 306
     private function peg_f3($body) { return $body; }
307 307
     private function peg_f4($name) {
308 308
             return new \Seufert\Hamle\TextNode\ScopeId(null, null, new \Seufert\Hamle\TextNode\ModelParam($name)); }
309
-    private function peg_f5($expr, $chain) { if(!$chain) return $expr;
309
+    private function peg_f5($expr, $chain) { if(!$chain) {
310
+      return $expr;
311
+    }
310 312
                            $top = array_pop($chain);
311 313
                            while($chain) { $top = array_pop($chain)->withChain($top); } return $expr->withChain($top); }
312 314
     private function peg_f6($sub) { return $sub; }
Please login to merge, or discard this patch.
php/hamle/Text/Filter.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -47,23 +47,23 @@  discard block
 block discarded – undo
47 47
 
48 48
   function __construct($s, Text $what) {
49 49
     var_dump($s, $what);
50
-    if(preg_match("/^([a-z_]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) {
50
+    if (preg_match("/^([a-z_]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) {
51 51
       $this->filter = $m[1];
52 52
       $this->vars = isset($m['vars']) && strlen($m['vars']) ? explode(',', $m['vars']) : [];
53
-      foreach($this->vars as $k=>$v)
54
-        $this->vars[$k] = str_replace("&comma;",',',$v);
55
-      if(isset($m['chained']) && strlen($m['chained'])) {
56
-        $this->chained = new Filter($m['chained'],$what);
53
+      foreach ($this->vars as $k=>$v)
54
+        $this->vars[$k] = str_replace("&comma;", ',', $v);
55
+      if (isset($m['chained']) && strlen($m['chained'])) {
56
+        $this->chained = new Filter($m['chained'], $what);
57 57
       }
58 58
     } else {
59 59
       throw new ParseError("Unable to parse filter expression \"$s\"");
60 60
     }
61
-    if(method_exists(Filter::class, $this->filter)) {
61
+    if (method_exists(Filter::class, $this->filter)) {
62 62
       $this->filter = Filter::class.'::'.$this->filter;
63
-    } elseif(in_array($this->filter, ['round', 'strtoupper', 'strtolower', 'ucfirst'])) {
64
-    } elseif($this->filter === 'json') {
63
+    } elseif (in_array($this->filter, ['round', 'strtoupper', 'strtolower', 'ucfirst'])) {
64
+    } elseif ($this->filter === 'json') {
65 65
       $this->filter = 'json_encode';
66
-    } elseif(self::$filterResolver && $filter = (self::$filterResolver)($this->filter)) {
66
+    } elseif (self::$filterResolver && $filter = (self::$filterResolver)($this->filter)) {
67 67
       $this->filter = $filter;
68 68
     } else {
69 69
       throw new ParseError("Unknown Filter Type \"{$this->filter}\"");
@@ -72,24 +72,24 @@  discard block
 block discarded – undo
72 72
   }
73 73
 
74 74
   function toHTML($escape = false) {
75
-    if($escape)
76
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
77
-    return "<?=" . $this->toPHP() . "?>";
75
+    if ($escape)
76
+      return "<?=htmlspecialchars(".$this->toPHP().")?>";
77
+    return "<?=".$this->toPHP()."?>";
78 78
   }
79 79
 
80 80
   function toPHPpre() {
81 81
     $pre = '';
82
-    if($this->chained)
82
+    if ($this->chained)
83 83
       $pre = $this->chained->toPHPpre();
84 84
     return "$pre{$this->filter}(";
85 85
   }
86 86
 
87 87
   function toPHPpost() {
88 88
     $post = '';
89
-    if($this->chained)
89
+    if ($this->chained)
90 90
       $post = $this->chained->toPHPpost();
91 91
     $o = '';
92
-    foreach($this->vars as $v)
92
+    foreach ($this->vars as $v)
93 93
       $o .= ','.$this->varToCode($v);
94 94
     return "$o)$post";
95 95
   }
@@ -104,24 +104,24 @@  discard block
 block discarded – undo
104 104
 
105 105
   static function itersplit($v, $sep = ",") {
106 106
     $o = [];
107
-    foreach(explode($sep, $v) as $k=>$i) {
108
-      if($i)
109
-        $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k];
107
+    foreach (explode($sep, $v) as $k=>$i) {
108
+      if ($i)
109
+        $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k];
110 110
     }
111 111
     return new WrapArray($o);
112 112
   }
113 113
 
114 114
   static function newlinebr($v) {
115
-    return str_replace("\n","<br />\n",$v);
115
+    return str_replace("\n", "<br />\n", $v);
116 116
   }
117 117
 
118 118
   static function replace($v, $src, $dst) {
119
-    return str_replace($src,$dst,$v);
119
+    return str_replace($src, $dst, $v);
120 120
   }
121 121
 
122 122
   static function ascents($v) {
123
-    $v = str_replace(['$',' ',','],'', $v);
124
-    return (int) round($v * 100,0);
123
+    $v = str_replace(['$', ' ', ','], '', $v);
124
+    return (int) round($v * 100, 0);
125 125
   }
126 126
 
127 127
 }
Please login to merge, or discard this patch.