Completed
Push — master ( 860016...7c00f5 )
by Chris
02:35
created
php/hamle/Text/Func.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
    */
44 44
   function __construct($s) {
45 45
     $m = array();
46
-    if (!preg_match('/^\$\((' . self::REGEX_FUNCSEL . '*)(.*)\)$/', $s, $m))
46
+    if (!preg_match('/^\$\(('.self::REGEX_FUNCSEL.'*)(.*)\)$/', $s, $m))
47 47
       throw new ParseError("Unable to read \$ func in '$s'");
48 48
     if (trim($m[2]))
49 49
       $this->sub = new FuncSub($m[2]);
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
     }
87 87
     $rand = false;
88 88
     if (preg_match_all('/\\^(-?)([a-zA-Z0-9\_]*)/', $s, $m)) {
89
-      foreach($m[0] as $k=>$mv)
89
+      foreach ($m[0] as $k=>$mv)
90 90
         if ($m[2][$k]) {
91
-          $dir = $m[1][$k] == "-"?Hamle\Hamle::SORT_DESCENDING:Hamle\Hamle::SORT_ASCENDING;
91
+          $dir = $m[1][$k] == "-" ? Hamle\Hamle::SORT_DESCENDING : Hamle\Hamle::SORT_ASCENDING;
92 92
           $att['sort'][$m[2][$k]] = $dir;
93 93
         } else $rand = true;
94 94
     }
95
-    if($rand)
95
+    if ($rand)
96 96
       $att['sort'] = [""=>$att['dir'] = Hamle\Hamle::SORT_RANDOM];
97 97
     return $att;
98 98
   }
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
    * @return string PHP Code
111 111
    */
112 112
   function toPHP() {
113
-    $sub = $this->sub ? "->" . $this->sub->toPHP() : "";
114
-    if($this->scope instanceof Scope) {
115
-      return $this->scope->toPHP() . $sub;
116
-    } elseif($this->scope === true) {
113
+    $sub = $this->sub ? "->".$this->sub->toPHP() : "";
114
+    if ($this->scope instanceof Scope) {
115
+      return $this->scope->toPHP().$sub;
116
+    } elseif ($this->scope === true) {
117 117
       return "Hamle\\Scope::get(0)$sub";
118 118
     }
119
-    $limit = Text::varToCode($this->sortlimit['sort']) . "," .
120
-        $this->sortlimit['limit'] . "," . $this->sortlimit['offset'];
119
+    $limit = Text::varToCode($this->sortlimit['sort']).",".
120
+        $this->sortlimit['limit'].",".$this->sortlimit['offset'];
121 121
     if (count($this->filt['tag']))
122
-      return "Hamle\\Run::modelTypeTags(" .
123
-      Text::varToCode($this->filt['tag']) . ",$limit)$sub";
122
+      return "Hamle\\Run::modelTypeTags(".
123
+      Text::varToCode($this->filt['tag']).",$limit)$sub";
124 124
     if (count($this->filt['id']))
125 125
       if (isset($this->filt['id']['*']) && count($this->filt['id']['*']) == 1)
126
-        return "Hamle\\Run::modelId(" .
127
-        Text::varToCode(current($this->filt['id']['*'])) .
126
+        return "Hamle\\Run::modelId(".
127
+        Text::varToCode(current($this->filt['id']['*'])).
128 128
         ",$limit)$sub";
129 129
       else
130
-        return "Hamle\\Run::modelTypeId(" .
131
-        Text::varToCode($this->filt['id']) . ",$limit)$sub";
130
+        return "Hamle\\Run::modelTypeId(".
131
+        Text::varToCode($this->filt['id']).",$limit)$sub";
132 132
     return "";
133 133
   }
134 134
 
Please login to merge, or discard this patch.
php/hamle/Text/SimpleVar.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,25 +33,25 @@
 block discarded – undo
33 33
   protected $filter;
34 34
 
35 35
   function __construct($s) {
36
-    if(FALSE !== $pos = strpos($s,'|')) {
37
-      $this->var = substr($s,1,$pos-1);
38
-      $this->filter = new Filter(substr($s, $pos+1), $this);
36
+    if (FALSE !== $pos = strpos($s, '|')) {
37
+      $this->var = substr($s, 1, $pos - 1);
38
+      $this->filter = new Filter(substr($s, $pos + 1), $this);
39 39
     } else {
40 40
       $this->var = substr($s, 1);
41 41
     }
42 42
   }
43 43
 
44 44
   function toHTML($escape = false) {
45
-    if($escape)
46
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
47
-    return "<?=" . $this->toPHP() . "?>";
45
+    if ($escape)
46
+      return "<?=htmlspecialchars(".$this->toPHP().")?>";
47
+    return "<?=".$this->toPHP()."?>";
48 48
   }
49 49
 
50 50
   function toPHP() {
51
-    return $this->filter?$this->filter->toPHP():$this->toPHPVar();
51
+    return $this->filter ? $this->filter->toPHP() : $this->toPHPVar();
52 52
   }
53 53
 
54 54
   function toPHPVar() {
55
-    return "Hamle\\Scope::get()->hamleGet(" . Text::varToCode($this->var) . ")";
55
+    return "Hamle\\Scope::get()->hamleGet(".Text::varToCode($this->var).")";
56 56
   }
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
php/hamle/Text/Comparison.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 
36 36
   function __construct($s, $mode = self::TOKEN_CONTROL) {
37 37
     $m = array();
38
-    if(preg_match('/^(.*) '.self::REGEX_COMP_OPER.' (.*)$/', $s, $m)) {
39
-      $this->param1 = new Text($m[1],Text::TOKEN_HTML);
40
-      $this->param2 = new Text($m[3],Text::TOKEN_HTML);
38
+    if (preg_match('/^(.*) '.self::REGEX_COMP_OPER.' (.*)$/', $s, $m)) {
39
+      $this->param1 = new Text($m[1], Text::TOKEN_HTML);
40
+      $this->param2 = new Text($m[3], Text::TOKEN_HTML);
41 41
       $this->operator = $m[2];
42 42
     } else
43
-      $this->param1 = new Text($s,Text::TOKEN_HTML);
43
+      $this->param1 = new Text($s, Text::TOKEN_HTML);
44 44
   }
45 45
 
46 46
 //  function __construct(String $p1, String $p2, $operator) {
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 //    $this->operator = $operator;
50 50
 //  }
51 51
   function toPHP() {
52
-    if(!$this->param2) return $this->param1->toPHP();
52
+    if (!$this->param2) return $this->param1->toPHP();
53 53
     $p1 = $this->param1->toPHP();
54 54
     $p2 = $this->param2->toPHP();
55
-    switch($this->operator) {
55
+    switch ($this->operator) {
56 56
       case "equals":
57 57
       case "equal":
58 58
         return $p1." == ".$p2;
Please login to merge, or discard this patch.
php/hamle/Text/FormField.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,10 +35,10 @@
 block discarded – undo
35 35
   }
36 36
 
37 37
   function toPHP() {
38
-    return '$form->getField(' . Text::varToCode($this->var) . ')->getValue()';
38
+    return '$form->getField('.Text::varToCode($this->var).')->getValue()';
39 39
   }
40 40
 
41 41
   function toHTML($escape = false) {
42
-    return '<?=' . $this->toPHP() . '?>';
42
+    return '<?='.$this->toPHP().'?>';
43 43
   }
44 44
 }
45 45
\ No newline at end of file
Please login to merge, or discard this patch.
php/hamle/Text/Complex.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
   protected $filter;
35 35
 
36 36
   function __construct($s) {
37
-    if(FALSE !== $pos = strpos($s,'|')) {
38
-      $this->filter = new Filter(substr($s, $pos+1), $this);
39
-      $s = substr($s,0,$pos);
37
+    if (FALSE !== $pos = strpos($s, '|')) {
38
+      $this->filter = new Filter(substr($s, $pos + 1), $this);
39
+      $s = substr($s, 0, $pos);
40 40
     }
41 41
     $s = explode("->", $s);
42
-    if(count($s) == 1) $s = explode("-!",$s[0]);
42
+    if (count($s) == 1) $s = explode("-!", $s[0]);
43 43
     if (!$s[0]) throw new ParseError("Unable to parse Complex Expression");
44 44
     if ($s[0][1] == "(")
45 45
       $this->func = new Text\Func($s[0]);
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
   }
53 53
 
54 54
   function toHTML($escape = false) {
55
-    if($escape)
56
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
57
-    return "<?=" . $this->toPHP() . "?>";
55
+    if ($escape)
56
+      return "<?=htmlspecialchars(".$this->toPHP().")?>";
57
+    return "<?=".$this->toPHP()."?>";
58 58
   }
59 59
   function toPHP() {
60
-    return $this->filter?$this->filter->toPHP():$this->toPHPVar();
60
+    return $this->filter ? $this->filter->toPHP() : $this->toPHPVar();
61 61
   }
62 62
   function toPHPVar() {
63 63
     if ($this->sel) {
64 64
       $sel = array();
65 65
       foreach ($this->sel as $s)
66 66
         $sel[] = "hamleGet('$s')";
67
-      return $this->func->toPHP() . "->" . implode('->', $sel);
67
+      return $this->func->toPHP()."->".implode('->', $sel);
68 68
     } else
69 69
       return $this->func->toPHP();
70 70
   }
Please login to merge, or discard this patch.
php/hamle/Text/FuncSub.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
    */
39 39
   function __construct($s) {
40 40
     $m = array();
41
-    if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m))
41
+    if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL.'+)(.*)$/', $s, $m))
42 42
       throw new ParseError("Unable to read \$ sub func in '$s'");
43 43
     if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT;
44 44
     elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD;
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
    * @return string
57 57
    */
58 58
   function toPHP() {
59
-    $limit = Hamle\Text::varToCode($this->sortlimit['sort']) . "," .
60
-        $this->sortlimit['limit'] . "," . $this->sortlimit['offset'] . "," .
59
+    $limit = Hamle\Text::varToCode($this->sortlimit['sort']).",".
60
+        $this->sortlimit['limit'].",".$this->sortlimit['offset'].",".
61 61
         $this->grouptype['grouptype'];
62
-    $sub = $this->sub ? "->" . $this->sub->toPHP() : "";
63
-    return "hamleRel(" . $this->dir . "," .
64
-    Hamle\Text::varToCode($this->filt['tag']) . ",$limit)$sub";
62
+    $sub = $this->sub ? "->".$this->sub->toPHP() : "";
63
+    return "hamleRel(".$this->dir.",".
64
+    Hamle\Text::varToCode($this->filt['tag']).",$limit)$sub";
65 65
   }
66 66
 }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.
php/hamle/Text/Filter.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
   protected $what;
39 39
 
40 40
   function __construct($s, Text $what) {
41
-    if(preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) {
41
+    if (preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) {
42 42
       $this->filter = $m[1];
43 43
       $this->vars = isset($m[3]) ? explode(',', $m[3]) : [];
44 44
     } else {
45 45
       throw new ParseError("Unable to parse filter expression \"$s\"");
46 46
     }
47
-    if(!in_array($this->filter, ['itersplit', 'newlinebr', 'round', 'strtoupper', 'strtolower', 'ucfirst'])) {
47
+    if (!in_array($this->filter, ['itersplit', 'newlinebr', 'round', 'strtoupper', 'strtolower', 'ucfirst'])) {
48 48
       throw new ParseError("Unknown Filter Type \"{$this->filter}\"");
49 49
     }
50
-    switch($this->filter) {
50
+    switch ($this->filter) {
51 51
       case "itersplit":
52 52
         $this->filter = "Seufert\\Hamle\\Text\\Filter::iterSplit";
53 53
         break;
@@ -59,29 +59,29 @@  discard block
 block discarded – undo
59 59
   }
60 60
 
61 61
   function toHTML($escape = false) {
62
-    if($escape)
63
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
64
-    return "<?=" . $this->toPHP() . "?>";
62
+    if ($escape)
63
+      return "<?=htmlspecialchars(".$this->toPHP().")?>";
64
+    return "<?=".$this->toPHP()."?>";
65 65
   }
66 66
 
67 67
   function toPHP() {
68
-    $o = [$this->what->toPHPVar()] ;
69
-    foreach($this->vars as $v)
68
+    $o = [$this->what->toPHPVar()];
69
+    foreach ($this->vars as $v)
70 70
       $o[] = $this->varToCode($v);
71
-    return "{$this->filter}(" . implode(',',$o) . ")";
71
+    return "{$this->filter}(".implode(',', $o).")";
72 72
   }
73 73
 
74 74
   static function iterSplit($v, $sep = ",") {
75 75
     $o = [];
76
-    foreach(explode($sep, $v) as $k=>$i) {
77
-      if($i)
78
-        $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k];
76
+    foreach (explode($sep, $v) as $k=>$i) {
77
+      if ($i)
78
+        $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k];
79 79
     }
80 80
     return new WrapArray($o);
81 81
   }
82 82
 
83 83
   static function newlineBr($v) {
84
-    return str_replace("\n","<br />\n",$v);
84
+    return str_replace("\n", "<br />\n", $v);
85 85
   }
86 86
 
87 87
 }
88 88
\ No newline at end of file
Please login to merge, or discard this patch.
php/hamle/Text/Scope.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,9 +41,9 @@
 block discarded – undo
41 41
 
42 42
   function toPHP() {
43 43
     if (is_numeric($this->scope))
44
-      return "Hamle\\Scope::get(" . Text::varToCode($this->scope) . ")";
44
+      return "Hamle\\Scope::get(".Text::varToCode($this->scope).")";
45 45
     else
46
-      return "Hamle\\Scope::getName(" . Text::varToCode($this->scope) . ")";
46
+      return "Hamle\\Scope::getName(".Text::varToCode($this->scope).")";
47 47
   }
48 48
 
49 49
   function toHTML($escape = false) {
Please login to merge, or discard this patch.