@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | $o = self::queryId($this->filters); |
| 41 | 41 | } else { |
| 42 | 42 | $o = |
| 43 | - '$ctx->hamleFindTypeTags($scope,' . |
|
| 44 | - self::queryParams($this->filters) . |
|
| 43 | + '$ctx->hamleFindTypeTags($scope,'. |
|
| 44 | + self::queryParams($this->filters). |
|
| 45 | 45 | ')'; |
| 46 | 46 | } |
| 47 | 47 | if ($this->immediate) { |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | ]; |
| 139 | 139 | if (!$type || $type === '*') { |
| 140 | 140 | $opt[0] = Text::varToCode($id); |
| 141 | - return '$ctx->hamleFindId($scope,' . join(',', $opt) . ')'; |
|
| 141 | + return '$ctx->hamleFindId($scope,'.join(',', $opt).')'; |
|
| 142 | 142 | } |
| 143 | - return '$ctx->hamleFindTypeId($scope,' . join(',', $opt) . ')'; |
|
| 143 | + return '$ctx->hamleFindTypeId($scope,'.join(',', $opt).')'; |
|
| 144 | 144 | } |
| 145 | 145 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function toPHP(): string |
| 35 | 35 | { |
| 36 | - $o = '$scope->namedModel(' . Text::varToCode($this->name) . ')'; |
|
| 36 | + $o = '$scope->namedModel('.Text::varToCode($this->name).')'; |
|
| 37 | 37 | if ($this->immediate) { |
| 38 | 38 | $o = $this->immediate->apply($o); |
| 39 | 39 | } |
@@ -44,9 +44,9 @@ |
||
| 44 | 44 | array_unshift($args, $out); |
| 45 | 45 | if ($this->name !== '') { |
| 46 | 46 | $o = |
| 47 | - "\$ctx->hamleFilter(\$scope,{$this->name}," . implode(',', $args) . ')'; |
|
| 47 | + "\$ctx->hamleFilter(\$scope,{$this->name},".implode(',', $args).')'; |
|
| 48 | 48 | } else { |
| 49 | - $o = "{$this->func}(" . join(',', $args) . ')'; |
|
| 49 | + $o = "{$this->func}(".join(',', $args).')'; |
|
| 50 | 50 | } |
| 51 | 51 | if ($this->chain) { |
| 52 | 52 | $o = $this->chain->apply($o); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | function __construct(string $tag, H\Tag $parentTag = null) |
| 51 | 51 | { |
| 52 | 52 | parent::__construct(); |
| 53 | - $this->o = "\$o" . self::$instCount++; |
|
| 53 | + $this->o = "\$o".self::$instCount++; |
|
| 54 | 54 | $this->type = strtolower($tag); |
| 55 | 55 | $this->var = ''; |
| 56 | 56 | if ($parentTag && $this->type == 'else') { |
@@ -70,15 +70,15 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | function renderStTag(): string |
| 72 | 72 | { |
| 73 | - $out = '<' . '?php '; |
|
| 73 | + $out = '<'.'?php '; |
|
| 74 | 74 | $scopeName = ''; |
| 75 | 75 | if ($this->type === 'if') { |
| 76 | 76 | $hsvcomp = new H\Text\Comparison($this->var); |
| 77 | - $out .= 'if(' . $hsvcomp->toPHP() . ') {'; |
|
| 78 | - return $out . "\n?>"; |
|
| 77 | + $out .= 'if('.$hsvcomp->toPHP().') {'; |
|
| 78 | + return $out."\n?>"; |
|
| 79 | 79 | } elseif ($this->type === 'else') { |
| 80 | 80 | $out .= '/* else */'; |
| 81 | - return $out . "\n?>"; |
|
| 81 | + return $out."\n?>"; |
|
| 82 | 82 | } |
| 83 | 83 | /** @var H\Text|null $hsv */ |
| 84 | 84 | $hsv = null; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | switch ($this->type) { |
| 95 | 95 | case 'each': |
| 96 | 96 | if ($hsv) { |
| 97 | - $out .= 'foreach(' . $hsv->toPHP() . " as {$this->o}) { \n"; |
|
| 97 | + $out .= 'foreach('.$hsv->toPHP()." as {$this->o}) { \n"; |
|
| 98 | 98 | } else { |
| 99 | 99 | $out .= "foreach(\$scope->model() as {$this->o}) { \n"; |
| 100 | 100 | } |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | if ($scopeName) { |
| 110 | 110 | $out .= |
| 111 | - '$scope = $scope->withModel(' . |
|
| 112 | - $hsv->toPHP() . |
|
| 111 | + '$scope = $scope->withModel('. |
|
| 112 | + $hsv->toPHP(). |
|
| 113 | 113 | "); \$scope->setNamedModel(\"$scopeName\")\n;"; |
| 114 | 114 | } else { |
| 115 | 115 | $out .= |
| 116 | - "if(({$this->o} = " . |
|
| 117 | - $hsv->toPHP() . |
|
| 118 | - ') && ' . |
|
| 116 | + "if(({$this->o} = ". |
|
| 117 | + $hsv->toPHP(). |
|
| 118 | + ') && '. |
|
| 119 | 119 | "{$this->o}->valid()) {\n"; |
| 120 | 120 | $out .= "\$scope = \$scope->withModel({$this->o});\n;"; |
| 121 | 121 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | $out .= "echo \$ctx->hamleInclude(\$scope, {$hsv->toPHP()});"; |
| 130 | 130 | } |
| 131 | - return $out . "\n?>"; |
|
| 131 | + return $out."\n?>"; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | function renderEnTag(): string |
| 143 | 143 | { |
| 144 | - $out = '<' . '?php '; |
|
| 144 | + $out = '<'.'?php '; |
|
| 145 | 145 | switch ($this->type) { |
| 146 | 146 | case 'each': |
| 147 | 147 | $out .= '$scope = $scope->lastScope(); '; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | if ($this->else) { |
| 167 | 167 | $out .= 'else{'; |
| 168 | 168 | } |
| 169 | - return $out . "\n?>"; |
|
| 169 | + return $out."\n?>"; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | function render(int $indent = 0, bool $minify = false): string |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $i = self::indentLevel($indent); |
| 178 | 178 | unset($m[0]); |
| 179 | 179 | switch (strlen($code) ? $code[0] : ($textcode ? $textcode : '')) { |
| 180 | - case '|': //Control Tag |
|
| 180 | + case '|' : //Control Tag |
|
| 181 | 181 | if ($code == '|snippet') { |
| 182 | 182 | $hTag = new Tag\Snippet($text); |
| 183 | 183 | } elseif ($code == '|form') { |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | } else { |
| 255 | 255 | throw new ParseError( |
| 256 | - "Unable to parse line {$this->lineNo}\n\"$line\" #" . |
|
| 256 | + "Unable to parse line {$this->lineNo}\n\"$line\" #". |
|
| 257 | 257 | preg_last_error(), |
| 258 | 258 | ); |
| 259 | 259 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | function toPHPFile(bool $minify = false):string |
| 276 | 276 | { |
| 277 | - return "<?php\n" . |
|
| 277 | + return "<?php\n". |
|
| 278 | 278 | "use Seufert\\Hamle;\n\n". |
| 279 | 279 | $this->compiledString($minify); |
| 280 | 280 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $this->lineNo + 1 < $this->lineCount && |
| 321 | 321 | (!trim($this->lines[$this->lineNo + 1]) || |
| 322 | 322 | preg_match( |
| 323 | - '/^(\s){' . $indent . '}((\s)+[^\s].*)$/', |
|
| 323 | + '/^(\s){'.$indent.'}((\s)+[^\s].*)$/', |
|
| 324 | 324 | $this->lines[$this->lineNo + 1], |
| 325 | 325 | $m, |
| 326 | 326 | )) |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | foreach ($this->indents as $k => $v) { |
| 344 | 344 | if ($v == $indent) { |
| 345 | - $this->indents = array_slice($this->indents, 0, 1 + (int) $k ); |
|
| 345 | + $this->indents = array_slice($this->indents, 0, 1 + (int) $k); |
|
| 346 | 346 | return $k; |
| 347 | 347 | } |
| 348 | 348 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | throw new Exception\NotFound("Unable to find HAMLE Template ($template)"); |
| 108 | 108 | } |
| 109 | 109 | $this->cacheFile = $this->setup->cachePath( |
| 110 | - str_replace('/', '-', $hamleFile) . '.php', |
|
| 110 | + str_replace('/', '-', $hamleFile).'.php', |
|
| 111 | 111 | ); |
| 112 | 112 | $this->setup->debugLog("Set cache file path to ({$this->cacheFile})"); |
| 113 | 113 | $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); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | if (!is_dir($dir)) { |
| 52 | 52 | mkdir($dir); |
| 53 | 53 | } |
| 54 | - return $dir . $f; |
|
| 54 | + return $dir.$f; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | 'newlinebr' => \Seufert\Hamle\Text\Filter::newlinebr(...$args), |
| 183 | 183 | 'replace' => \Seufert\Hamle\Text\Filter::replace(...$args), |
| 184 | 184 | 'ascents' => \Seufert\Hamle\Text\Filter::ascents(...$args), |
| 185 | - default => throw new RuntimeException('Unknown Filter: ' . $filter) |
|
| 185 | + default => throw new RuntimeException('Unknown Filter: '.$filter) |
|
| 186 | 186 | }; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Scope implements \Seufert\Hamle\Runtime\Scope |
| 14 | 14 | { |
| 15 | - public Scope|null $lastScope = null; |
|
| 15 | + public Scope | null $lastScope = null; |
|
| 16 | 16 | |
| 17 | 17 | /** @var list<Model> $parents Parent Scopes */ |
| 18 | 18 | public array $parents = []; |
@@ -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 | |