@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ]); |
71 | 71 | } catch (SyntaxError $e) { |
72 | 72 | throw new ParseError( |
73 | - 'Unable to parse:' . $s . "\n\n" . $e->getMessage(), |
|
73 | + 'Unable to parse:'.$s."\n\n".$e->getMessage(), |
|
74 | 74 | 0, |
75 | 75 | $e, |
76 | 76 | ); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | self::varToCode($limit), |
142 | 142 | self::varToCode($offset), |
143 | 143 | ]; |
144 | - return 'Hamle\Run::modelTypeId(' . join(',', $opt) . ')'; |
|
144 | + return 'Hamle\Run::modelTypeId('.join(',', $opt).')'; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | function toHTML(bool $escape = false): string |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | } |
157 | 157 | break; |
158 | 158 | case 'scopeName': |
159 | - $out .= '<?=' . self::renderScopeName($node) . '?>'; |
|
159 | + $out .= '<?='.self::renderScopeName($node).'?>'; |
|
160 | 160 | break; |
161 | 161 | case 'scopeThis': |
162 | - $out .= '<?=' . self::renderScopeThis($node) . '?>'; |
|
162 | + $out .= '<?='.self::renderScopeThis($node).'?>'; |
|
163 | 163 | break; |
164 | 164 | case 'expr': |
165 | - $out .= '<?=' . self::renderExpr($node) . '?>'; |
|
165 | + $out .= '<?='.self::renderExpr($node).'?>'; |
|
166 | 166 | break; |
167 | 167 | default: |
168 | - throw new \RuntimeException('Invalid Node:' . $node['type']); |
|
168 | + throw new \RuntimeException('Invalid Node:'.$node['type']); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | return $out; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $out[] = self::renderExpr($node); |
195 | 195 | break; |
196 | 196 | default: |
197 | - throw new \RuntimeException('Invalid Node:' . $node['type']); |
|
197 | + throw new \RuntimeException('Invalid Node:'.$node['type']); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | return join('.', $out); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | function doEval(): mixed |
204 | 204 | { |
205 | - return eval('use Seufert\Hamle; return ' . $this->toPHP() . ';'); |
|
205 | + return eval('use Seufert\Hamle; return '.$this->toPHP().';'); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | static function varToCode(mixed $var): mixed |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | if (is_array($var)) { |
211 | 211 | $code = []; |
212 | 212 | foreach ($var as $key => $value) { |
213 | - $code[] = self::varToCode($key) . '=>' . self::varToCode($value); |
|
213 | + $code[] = self::varToCode($key).'=>'.self::varToCode($value); |
|
214 | 214 | } |
215 | - return 'array(' . implode(',', $code) . ')'; //remove unnecessary coma |
|
215 | + return 'array('.implode(',', $code).')'; //remove unnecessary coma |
|
216 | 216 | } |
217 | 217 | if (is_bool($var)) { |
218 | 218 | return $var ? 'TRUE' : 'FALSE'; |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | return $var->toPHP(); |
225 | 225 | } |
226 | 226 | if (strpos($var, "\n") !== false) { |
227 | - return '"' . |
|
227 | + return '"'. |
|
228 | 228 | str_replace( |
229 | 229 | ['\\', '$', '"', "\n"], |
230 | 230 | ['\\\\', '\$', '\\"', '\\n'], |
231 | 231 | $var, |
232 | - ) . |
|
232 | + ). |
|
233 | 233 | '"'; |
234 | 234 | } |
235 | - return "'" . |
|
236 | - str_replace(['\\', '$', "'"], ['\\\\', '$', "\\'"], $var) . |
|
235 | + return "'". |
|
236 | + str_replace(['\\', '$', "'"], ['\\\\', '$', "\\'"], $var). |
|
237 | 237 | "'"; |
238 | 238 | } |
239 | 239 |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | } |
93 | 93 | if (!$baseModel instanceof Model) { |
94 | 94 | throw new Exception\Unsupported( |
95 | - 'Unsupported Model(' . |
|
96 | - get_class($baseModel) . |
|
95 | + 'Unsupported Model('. |
|
96 | + get_class($baseModel). |
|
97 | 97 | ') Type was passed, it must implement hamleModel', |
98 | 98 | ); |
99 | 99 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | throw new Exception\NotFound("Unable to find HAMLE Template ($template)"); |
129 | 129 | } |
130 | 130 | $this->cacheFile = $this->setup->cachePath( |
131 | - str_replace('/', '-', $hamleFile) . '.php', |
|
131 | + str_replace('/', '-', $hamleFile).'.php', |
|
132 | 132 | ); |
133 | 133 | $this->setup->debugLog("Set cache file path to ({$this->cacheFile})"); |
134 | 134 | $cacheFileAge = is_file($this->cacheFile) ? filemtime($this->cacheFile) : 0; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | function string(string $hamleString): void |
194 | 194 | { |
195 | 195 | $md5 = md5($hamleString); |
196 | - $stringId = substr($md5, 0, 12) . substr($md5, 24, 8); |
|
196 | + $stringId = substr($md5, 0, 12).substr($md5, 24, 8); |
|
197 | 197 | $this->cacheFile = $this->setup->cachePath("string.$stringId.hamle.php"); |
198 | 198 | if (!is_file($this->cacheFile)) { |
199 | 199 | $this->parse($hamleString); |
@@ -32,7 +32,7 @@ |
||
32 | 32 | static function fromParser( |
33 | 33 | array $chars, |
34 | 34 | ?Evaluated $expr = null, |
35 | - string|StringLit|StringConcat $rhs = null |
|
35 | + string | StringLit | StringConcat $rhs = null |
|
36 | 36 | ): self { |
37 | 37 | $o = []; |
38 | 38 | if ($chars) { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $this->filters = $filters; |
20 | 20 | } |
21 | 21 | |
22 | - static function for(string $rel, array $filters): self |
|
22 | + static function for (string $rel, array $filters): self |
|
23 | 23 | { |
24 | 24 | return new self( |
25 | 25 | $rel === '>' ? Hamle::REL_CHILD : Hamle::REL_PARENT, |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | public function apply(string $out): string |
31 | 31 | { |
32 | 32 | $out = |
33 | - $out . |
|
34 | - "->hamleRel({$this->rel}," . |
|
35 | - Query::queryParams($this->filters, true) . |
|
33 | + $out. |
|
34 | + "->hamleRel({$this->rel},". |
|
35 | + Query::queryParams($this->filters, true). |
|
36 | 36 | ')'; |
37 | 37 | if ($this->chain) { |
38 | 38 | $out = $this->chain->apply($out); |
@@ -50,9 +50,9 @@ |
||
50 | 50 | function toPHP(): string |
51 | 51 | { |
52 | 52 | if (is_numeric($this->scope)) { |
53 | - return 'Hamle\\Scope::get(' . Text::varToCode($this->scope) . ')'; |
|
53 | + return 'Hamle\\Scope::get('.Text::varToCode($this->scope).')'; |
|
54 | 54 | } else { |
55 | - return 'Hamle\\Scope::getName(' . Text::varToCode($this->scope) . ')'; |
|
55 | + return 'Hamle\\Scope::getName('.Text::varToCode($this->scope).')'; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public function __construct($s) |
51 | 51 | { |
52 | 52 | $m = []; |
53 | - if (!preg_match('/^\$\((' . self::REGEX_FUNCSEL . '*)(.*)\)$/', $s, $m)) { |
|
53 | + if (!preg_match('/^\$\(('.self::REGEX_FUNCSEL.'*)(.*)\)$/', $s, $m)) { |
|
54 | 54 | throw new ParseError("Unable to read \$ func in '$s'"); |
55 | 55 | } |
56 | 56 | if (trim($m[2])) { |
@@ -137,31 +137,31 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function toPHP(): string |
139 | 139 | { |
140 | - $sub = $this->sub ? '->' . $this->sub->toPHP() : ''; |
|
140 | + $sub = $this->sub ? '->'.$this->sub->toPHP() : ''; |
|
141 | 141 | if ($this->scope instanceof Scope) { |
142 | - return $this->scope->toPHP() . $sub; |
|
142 | + return $this->scope->toPHP().$sub; |
|
143 | 143 | } elseif ($this->scope === true) { |
144 | 144 | return "Hamle\\Scope::get(0)$sub"; |
145 | 145 | } |
146 | 146 | $limit = |
147 | - Text::varToCode($this->sortlimit['sort']) . |
|
148 | - ',' . |
|
149 | - $this->sortlimit['limit'] . |
|
150 | - ',' . |
|
147 | + Text::varToCode($this->sortlimit['sort']). |
|
148 | + ','. |
|
149 | + $this->sortlimit['limit']. |
|
150 | + ','. |
|
151 | 151 | $this->sortlimit['offset']; |
152 | 152 | if (count($this->filt['tag'])) { |
153 | - return 'Hamle\\Run::modelTypeTags(' . |
|
154 | - Text::varToCode($this->filt['tag']) . |
|
153 | + return 'Hamle\\Run::modelTypeTags('. |
|
154 | + Text::varToCode($this->filt['tag']). |
|
155 | 155 | ",$limit)$sub"; |
156 | 156 | } |
157 | 157 | if (count($this->filt['id'])) { |
158 | 158 | if (isset($this->filt['id']['*']) && count($this->filt['id']['*']) == 1) { |
159 | - return 'Hamle\\Run::modelId(' . |
|
160 | - Text::varToCode(current($this->filt['id']['*'])) . |
|
159 | + return 'Hamle\\Run::modelId('. |
|
160 | + Text::varToCode(current($this->filt['id']['*'])). |
|
161 | 161 | ",$limit)$sub"; |
162 | 162 | } else { |
163 | - return 'Hamle\\Run::modelTypeId(' . |
|
164 | - Text::varToCode($this->filt['id']) . |
|
163 | + return 'Hamle\\Run::modelTypeId('. |
|
164 | + Text::varToCode($this->filt['id']). |
|
165 | 165 | ",$limit)$sub"; |
166 | 166 | } |
167 | 167 | } |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | function toHTML(bool $escape = false): string |
49 | 49 | { |
50 | 50 | if ($escape) { |
51 | - return '<?=htmlspecialchars(' . $this->toPHP() . ')?>'; |
|
51 | + return '<?=htmlspecialchars('.$this->toPHP().')?>'; |
|
52 | 52 | } |
53 | - return '<?=' . $this->toPHP() . '?>'; |
|
53 | + return '<?='.$this->toPHP().'?>'; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | function toPHP(): string |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | function toPHPVar(): string |
62 | 62 | { |
63 | - return 'Hamle\\Scope::get()->hamleGet(' . Text::varToCode($this->var) . ')'; |
|
63 | + return 'Hamle\\Scope::get()->hamleGet('.Text::varToCode($this->var).')'; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function getOrCreateModel(Model $parent = null): Model |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | function toHTML(bool $escape = false): string |
65 | 65 | { |
66 | 66 | if ($escape) { |
67 | - return '<?=htmlspecialchars(' . $this->toPHP() . ')?>'; |
|
67 | + return '<?=htmlspecialchars('.$this->toPHP().')?>'; |
|
68 | 68 | } |
69 | - return '<?=' . $this->toPHP() . '?>'; |
|
69 | + return '<?='.$this->toPHP().'?>'; |
|
70 | 70 | } |
71 | 71 | function toPHP(): string |
72 | 72 | { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | foreach ($this->sel as $s) { |
81 | 81 | $sel[] = "hamleGet('$s')"; |
82 | 82 | } |
83 | - return $this->func->toPHP() . '->' . implode('->', $sel); |
|
83 | + return $this->func->toPHP().'->'.implode('->', $sel); |
|
84 | 84 | } else { |
85 | 85 | return $this->func->toPHP(); |
86 | 86 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | return $this->func->getOrCreateModel($parent); |
96 | 96 | } |
97 | 97 | throw new RuntimeException( |
98 | - 'Unsupported func type encountered:' . |
|
98 | + 'Unsupported func type encountered:'. |
|
99 | 99 | ($this->func ? get_class($this->func) : 'Unknown'), |
100 | 100 | ); |
101 | 101 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $model = $this->getOrCreateModel(); |
115 | 115 | if (!$model instanceof WriteModel) { |
116 | 116 | throw new RuntimeException( |
117 | - 'Can only set values on WriteModel, got ' . get_class($model), |
|
117 | + 'Can only set values on WriteModel, got '.get_class($model), |
|
118 | 118 | ); |
119 | 119 | } |
120 | 120 | $model->hamleSet($this->sel[0], $value); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $m = []; |
44 | 44 | if ( |
45 | - !preg_match('/^ +([><]) +(' . self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m) |
|
45 | + !preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL.'+)(.*)$/', $s, $m) |
|
46 | 46 | ) { |
47 | 47 | throw new ParseError("Unable to read \$ sub func in '$s'"); |
48 | 48 | } |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | public function toPHP(): string |
72 | 72 | { |
73 | 73 | $limit = |
74 | - Hamle\Text::varToCode($this->sortlimit['sort']) . |
|
75 | - ',' . |
|
76 | - $this->sortlimit['limit'] . |
|
77 | - ',' . |
|
78 | - $this->sortlimit['offset'] . |
|
79 | - ',' . |
|
74 | + Hamle\Text::varToCode($this->sortlimit['sort']). |
|
75 | + ','. |
|
76 | + $this->sortlimit['limit']. |
|
77 | + ','. |
|
78 | + $this->sortlimit['offset']. |
|
79 | + ','. |
|
80 | 80 | $this->grouptype['grouptype']; |
81 | - $sub = $this->sub ? '->' . $this->sub->toPHP() : ''; |
|
82 | - return 'hamleRel(' . |
|
83 | - $this->dir . |
|
84 | - ',' . |
|
85 | - Hamle\Text::varToCode($this->filt['tag']) . |
|
81 | + $sub = $this->sub ? '->'.$this->sub->toPHP() : ''; |
|
82 | + return 'hamleRel('. |
|
83 | + $this->dir. |
|
84 | + ','. |
|
85 | + Hamle\Text::varToCode($this->filt['tag']). |
|
86 | 86 | ",$limit)$sub"; |
87 | 87 | } |
88 | 88 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | if (!$model->valid()) { |
102 | 102 | if (!$parent instanceof Hamle\WriteModel) { |
103 | 103 | throw new \RuntimeException( |
104 | - 'Cant create model, ' . |
|
105 | - get_class($parent) . |
|
104 | + 'Cant create model, '. |
|
105 | + get_class($parent). |
|
106 | 106 | ' must implement Hamle\\WriteModel.', |
107 | 107 | ); |
108 | 108 | } |