@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | ]); |
| 72 | 72 | } catch (SyntaxError $e) { |
| 73 | 73 | throw new ParseError( |
| 74 | - 'Unable to parse:' . $s . "\n\n" . $e->getMessage(), |
|
| 74 | + 'Unable to parse:'.$s."\n\n".$e->getMessage(), |
|
| 75 | 75 | 0, |
| 76 | 76 | $e, |
| 77 | 77 | ); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | self::varToCode($limit), |
| 143 | 143 | self::varToCode($offset), |
| 144 | 144 | ]; |
| 145 | - return '$ctx->hamleFindTypeId($scope,' . join(',', $opt) . ')'; |
|
| 145 | + return '$ctx->hamleFindTypeId($scope,'.join(',', $opt).')'; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | function toHTML(bool $escape = false): string |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | break; |
| 159 | 159 | case 'scopeName': |
| 160 | - $out .= '<?=' . self::renderScopeName($node) . '?>'; |
|
| 160 | + $out .= '<?='.self::renderScopeName($node).'?>'; |
|
| 161 | 161 | break; |
| 162 | 162 | case 'scopeThis': |
| 163 | - $out .= '<?=' . self::renderScopeThis($node) . '?>'; |
|
| 163 | + $out .= '<?='.self::renderScopeThis($node).'?>'; |
|
| 164 | 164 | break; |
| 165 | 165 | case 'expr': |
| 166 | - $out .= '<?=' . self::renderExpr($node) . '?>'; |
|
| 166 | + $out .= '<?='.self::renderExpr($node).'?>'; |
|
| 167 | 167 | break; |
| 168 | 168 | default: |
| 169 | - throw new \RuntimeException('Invalid Node:' . $node['type']); |
|
| 169 | + throw new \RuntimeException('Invalid Node:'.$node['type']); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | return $out; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $out[] = self::renderExpr($node); |
| 196 | 196 | break; |
| 197 | 197 | default: |
| 198 | - throw new \RuntimeException('Invalid Node:' . $node['type']); |
|
| 198 | + throw new \RuntimeException('Invalid Node:'.$node['type']); |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | return join('.', $out); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | function doEval(): mixed |
| 205 | 205 | { |
| 206 | - return eval('use Seufert\Hamle; return ' . $this->toPHP() . ';'); |
|
| 206 | + return eval('use Seufert\Hamle; return '.$this->toPHP().';'); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | static function varToCode(mixed $var): mixed |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | if (is_array($var)) { |
| 212 | 212 | $code = []; |
| 213 | 213 | foreach ($var as $key => $value) { |
| 214 | - $code[] = self::varToCode($key) . '=>' . self::varToCode($value); |
|
| 214 | + $code[] = self::varToCode($key).'=>'.self::varToCode($value); |
|
| 215 | 215 | } |
| 216 | - return 'array(' . implode(',', $code) . ')'; //remove unnecessary coma |
|
| 216 | + return 'array('.implode(',', $code).')'; //remove unnecessary coma |
|
| 217 | 217 | } |
| 218 | 218 | if (is_bool($var)) { |
| 219 | 219 | return $var ? 'TRUE' : 'FALSE'; |
@@ -226,16 +226,16 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | $var = (string) $var; |
| 228 | 228 | if (strpos($var, "\n") !== false) { |
| 229 | - return '"' . |
|
| 229 | + return '"'. |
|
| 230 | 230 | str_replace( |
| 231 | 231 | ['\\', '$', '"', "\n"], |
| 232 | 232 | ['\\\\', '\$', '\\"', '\\n'], |
| 233 | 233 | $var, |
| 234 | - ) . |
|
| 234 | + ). |
|
| 235 | 235 | '"'; |
| 236 | 236 | } |
| 237 | - return "'" . |
|
| 238 | - str_replace(['\\', '$', "'"], ['\\\\', '$', "\\'"], $var) . |
|
| 237 | + return "'". |
|
| 238 | + str_replace(['\\', '$', "'"], ['\\\\', '$', "\\'"], $var). |
|
| 239 | 239 | "'"; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | function toHTML(bool $escape = false): string |
| 50 | 50 | { |
| 51 | 51 | if ($escape) { |
| 52 | - return '<?=htmlspecialchars(' . $this->toPHP() . ')?>'; |
|
| 52 | + return '<?=htmlspecialchars('.$this->toPHP().')?>'; |
|
| 53 | 53 | } |
| 54 | - return '<?=' . $this->toPHP() . '?>'; |
|
| 54 | + return '<?='.$this->toPHP().'?>'; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | function toPHP(): string |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | function toPHPVar(): string |
| 63 | 63 | { |
| 64 | - return '$scope->model()->hamleGet(' . Text::varToCode($this->var) . ')'; |
|
| 64 | + return '$scope->model()->hamleGet('.Text::varToCode($this->var).')'; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | function getOrCreateModel( |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | function toHTML(bool $escape = false): string |
| 66 | 66 | { |
| 67 | 67 | if ($escape) { |
| 68 | - return '<?=htmlspecialchars(' . $this->toPHP() . ')?>'; |
|
| 68 | + return '<?=htmlspecialchars('.$this->toPHP().')?>'; |
|
| 69 | 69 | } |
| 70 | - return '<?=' . $this->toPHP() . '?>'; |
|
| 70 | + return '<?='.$this->toPHP().'?>'; |
|
| 71 | 71 | } |
| 72 | 72 | function toPHP(): string |
| 73 | 73 | { |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | foreach ($this->sel as $s) { |
| 82 | 82 | $sel[] = "hamleGet('$s')"; |
| 83 | 83 | } |
| 84 | - return $this->func->toPHP() . '->' . implode('->', $sel); |
|
| 84 | + return $this->func->toPHP().'->'.implode('->', $sel); |
|
| 85 | 85 | } else { |
| 86 | 86 | return $this->func->toPHP(); |
| 87 | 87 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | return $this->func->getOrCreateModel($scope, $ctx, $parent); |
| 97 | 97 | } |
| 98 | 98 | throw new RuntimeException( |
| 99 | - 'Unsupported func type encountered:' . |
|
| 99 | + 'Unsupported func type encountered:'. |
|
| 100 | 100 | ($this->func ? get_class($this->func) : 'Unknown'), |
| 101 | 101 | ); |
| 102 | 102 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $model = $this->getOrCreateModel($scope, $ctx); |
| 119 | 119 | if (!$model instanceof WriteModel) { |
| 120 | 120 | throw new RuntimeException( |
| 121 | - 'Can only set values on WriteModel, got ' . get_class($model), |
|
| 121 | + 'Can only set values on WriteModel, got '.get_class($model), |
|
| 122 | 122 | ); |
| 123 | 123 | } |
| 124 | 124 | $model->hamleSet($this->sel[0], $value); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public function __construct($s) |
| 52 | 52 | { |
| 53 | 53 | $m = []; |
| 54 | - if (!preg_match('/^\$\((' . self::REGEX_FUNCSEL . '*)(.*)\)$/', $s, $m)) { |
|
| 54 | + if (!preg_match('/^\$\(('.self::REGEX_FUNCSEL.'*)(.*)\)$/', $s, $m)) { |
|
| 55 | 55 | throw new ParseError("Unable to read \$ func in '$s'"); |
| 56 | 56 | } |
| 57 | 57 | if (trim($m[2])) { |
@@ -138,31 +138,31 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function toPHP(): string |
| 140 | 140 | { |
| 141 | - $sub = $this->sub ? '->' . $this->sub->toPHP() : ''; |
|
| 141 | + $sub = $this->sub ? '->'.$this->sub->toPHP() : ''; |
|
| 142 | 142 | if ($this->scope instanceof Scope) { |
| 143 | - return $this->scope->toPHP() . $sub; |
|
| 143 | + return $this->scope->toPHP().$sub; |
|
| 144 | 144 | } elseif ($this->scope === true) { |
| 145 | 145 | return "Hamle\\Scope::get(0)$sub"; |
| 146 | 146 | } |
| 147 | 147 | $limit = |
| 148 | - Text::varToCode($this->sortlimit['sort']) . |
|
| 149 | - ',' . |
|
| 150 | - $this->sortlimit['limit'] . |
|
| 151 | - ',' . |
|
| 148 | + Text::varToCode($this->sortlimit['sort']). |
|
| 149 | + ','. |
|
| 150 | + $this->sortlimit['limit']. |
|
| 151 | + ','. |
|
| 152 | 152 | $this->sortlimit['offset']; |
| 153 | 153 | if (count($this->filt['tag'])) { |
| 154 | - return '$ctx->hamleFindTypeTags($scope,' . |
|
| 155 | - Text::varToCode($this->filt['tag']) . |
|
| 154 | + return '$ctx->hamleFindTypeTags($scope,'. |
|
| 155 | + Text::varToCode($this->filt['tag']). |
|
| 156 | 156 | ",$limit)$sub"; |
| 157 | 157 | } |
| 158 | 158 | if (count($this->filt['id'])) { |
| 159 | 159 | if (isset($this->filt['id']['*']) && count($this->filt['id']['*']) == 1) { |
| 160 | - return '$ctx->hamleFindId($scope,' . |
|
| 161 | - Text::varToCode(current($this->filt['id']['*'])) . |
|
| 160 | + return '$ctx->hamleFindId($scope,'. |
|
| 161 | + Text::varToCode(current($this->filt['id']['*'])). |
|
| 162 | 162 | ",$limit)$sub"; |
| 163 | 163 | } else { |
| 164 | - return '$ctx->hamleFindTypeId($scope,' . |
|
| 165 | - Text::varToCode($this->filt['id']) . |
|
| 164 | + return '$ctx->hamleFindTypeId($scope,'. |
|
| 165 | + Text::varToCode($this->filt['id']). |
|
| 166 | 166 | ",$limit)$sub"; |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -51,9 +51,9 @@ |
||
| 51 | 51 | function toPHP(): string |
| 52 | 52 | { |
| 53 | 53 | if (is_numeric($this->scope)) { |
| 54 | - return '$scope->modelNum(' . Text::varToCode($this->scope) . ')'; |
|
| 54 | + return '$scope->modelNum('.Text::varToCode($this->scope).')'; |
|
| 55 | 55 | } else { |
| 56 | - return '$scope->namedModel(' . Text::varToCode($this->scope) . ')'; |
|
| 56 | + return '$scope->namedModel('.Text::varToCode($this->scope).')'; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |