@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | const FIND_DOLLARVAR = 0x02; |
| 52 | 52 | const FIND_BARDOLLAR = 0x04; |
| 53 | 53 | |
| 54 | - const START_RULE_MAP = [self::TOKEN_HTML => 'HtmlInput', self::TOKEN_CODE => 'CodeInput',self::TOKEN_CONTROL => 'ControlInput']; |
|
| 54 | + const START_RULE_MAP = [self::TOKEN_HTML => 'HtmlInput', self::TOKEN_CODE => 'CodeInput', self::TOKEN_CONTROL => 'ControlInput']; |
|
| 55 | 55 | |
| 56 | 56 | protected $mode; |
| 57 | 57 | |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | // var_dump($s); |
| 63 | 63 | $this->mode = $mode; |
| 64 | - $this->tree = (new Parser())->parse($s,['startRule' => self::START_RULE_MAP[$mode]]); |
|
| 64 | + $this->tree = (new Parser())->parse($s, ['startRule' => self::START_RULE_MAP[$mode]]); |
|
| 65 | 65 | // var_dump($this->tree); |
| 66 | - if(!$this->tree instanceof Doc) { |
|
| 66 | + if (!$this->tree instanceof Doc) { |
|
| 67 | 67 | $this->tree = new Doc(is_array($this->tree) ? $this->tree : [$this->tree]); |
| 68 | 68 | } |
| 69 | 69 | // $m = []; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | $func = $filter['func']; |
| 116 | 116 | if (method_exists(Filter::class, $func)) { |
| 117 | - $func = Filter::class . '::' . $func; |
|
| 117 | + $func = Filter::class.'::'.$func; |
|
| 118 | 118 | } elseif (in_array($func, ['round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
| 119 | 119 | } elseif ($func === 'json') { |
| 120 | 120 | $func = 'json_encode'; |
@@ -124,14 +124,14 @@ discard block |
||
| 124 | 124 | throw new ParseError("Unknown Filter Type \"{$func}\""); |
| 125 | 125 | } |
| 126 | 126 | $args = join(',', array_map(function($v) { |
| 127 | - if(is_array($v) && $v['type'] ?? false === 'expr') { |
|
| 127 | + if (is_array($v) && $v['type'] ?? false === 'expr') { |
|
| 128 | 128 | return self::renderExpr($v); |
| 129 | 129 | } else |
| 130 | 130 | return self::varToCode($v); |
| 131 | 131 | } , $filter['args'])); |
| 132 | - if(strlen($args)) $args = ','.$args; |
|
| 133 | - $o = "$func($o" . $args . ")"; |
|
| 134 | - if($filter['chain'] ?? false) { |
|
| 132 | + if (strlen($args)) $args = ','.$args; |
|
| 133 | + $o = "$func($o".$args.")"; |
|
| 134 | + if ($filter['chain'] ?? false) { |
|
| 135 | 135 | $o = self::addFilter($o, $filter['chain']); |
| 136 | 136 | } |
| 137 | 137 | return $o; |
@@ -139,21 +139,21 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | static function renderScopeThis($n) |
| 141 | 141 | { |
| 142 | - $o = 'Hamle\Scope::get()->hamleGet(' . self::varToCode($n['name']) . ')'; |
|
| 142 | + $o = 'Hamle\Scope::get()->hamleGet('.self::varToCode($n['name']).')'; |
|
| 143 | 143 | $o = self::addParams($o, $n['param'] ?? []); |
| 144 | 144 | return $o; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | static function renderScopeId($n) |
| 148 | 148 | { |
| 149 | - $o = 'Hamle\Scope::get(' . $n['id'] . ')'; |
|
| 149 | + $o = 'Hamle\Scope::get('.$n['id'].')'; |
|
| 150 | 150 | $o = self::addParams($o, $n['param'] ?? []); |
| 151 | 151 | return $o; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | static function renderScopeName($n) |
| 155 | 155 | { |
| 156 | - $o = 'Hamle\Scope::getName(' . self::varToCode($n['name']) . ')'; |
|
| 156 | + $o = 'Hamle\Scope::getName('.self::varToCode($n['name']).')'; |
|
| 157 | 157 | $o = self::addParams($o, $n['param'] ?? []); |
| 158 | 158 | return $o; |
| 159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | static function addParams(string $o, array $params) |
| 162 | 162 | { |
| 163 | 163 | while ($params['type'] ?? null === 'sub') { |
| 164 | - $o .= '->hamleGet(' . self::varToCode($params['name']) . ')'; |
|
| 164 | + $o .= '->hamleGet('.self::varToCode($params['name']).')'; |
|
| 165 | 165 | $params = $params['params'] ?? []; |
| 166 | 166 | } |
| 167 | 167 | return $o; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | static function addRel(string $o, array $query, string $rel): string |
| 171 | 171 | { |
| 172 | 172 | $r = $rel === 'child' ? Hamle::REL_CHILD : Hamle::REL_PARENT; |
| 173 | - $o = $o . "->hamleRel(" . self::varToCode($r) . ',' . self::queryParams($query, true) . ')'; |
|
| 173 | + $o = $o."->hamleRel(".self::varToCode($r).','.self::queryParams($query, true).')'; |
|
| 174 | 174 | return $o; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | self::varToCode($limit), |
| 231 | 231 | self::varToCode($offset) |
| 232 | 232 | ]; |
| 233 | - return 'Hamle\Run::modelTypeId(' . join(',', $opt) . ')'; |
|
| 233 | + return 'Hamle\Run::modelTypeId('.join(',', $opt).')'; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | static function renderQuery($n) |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } elseif ($id !== null) { |
| 250 | 250 | $o = self::queryId($n['query']); |
| 251 | 251 | } else { |
| 252 | - $o = 'Hamle\Run::modelTypeTags(' . self::queryParams($n['query']) . ')'; |
|
| 252 | + $o = 'Hamle\Run::modelTypeTags('.self::queryParams($n['query']).')'; |
|
| 253 | 253 | } |
| 254 | 254 | if ($n['sub'] ?? []) { |
| 255 | 255 | $o = self::addRel($o, $n['sub'], $n['rel']); |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $o = self::renderQuery($expr['body']); |
| 277 | 277 | break; |
| 278 | 278 | default: |
| 279 | - throw new \RuntimeException('Invalid Node: ' . $expr['body']['type']); |
|
| 279 | + throw new \RuntimeException('Invalid Node: '.$expr['body']['type']); |
|
| 280 | 280 | } |
| 281 | 281 | if ($expr['body']['filter'] ?? false) { |
| 282 | 282 | $o = self::addFilter($o, $expr['body']['filter']); |
@@ -295,16 +295,16 @@ discard block |
||
| 295 | 295 | $out .= $node['body']; |
| 296 | 296 | break; |
| 297 | 297 | case 'scopeName': |
| 298 | - $out .= '<?=' . self::renderScopeName($node) . '?>'; |
|
| 298 | + $out .= '<?='.self::renderScopeName($node).'?>'; |
|
| 299 | 299 | break; |
| 300 | 300 | case 'scopeThis': |
| 301 | - $out .= '<?=' . self::renderScopeThis($node) . '?>'; |
|
| 301 | + $out .= '<?='.self::renderScopeThis($node).'?>'; |
|
| 302 | 302 | break; |
| 303 | 303 | case 'expr': |
| 304 | - $out .= '<?=' . self::renderExpr($node) . "?>"; |
|
| 304 | + $out .= '<?='.self::renderExpr($node)."?>"; |
|
| 305 | 305 | break; |
| 306 | 306 | default: |
| 307 | - throw new \RuntimeException('Invalid Node:' . $node['type']); |
|
| 307 | + throw new \RuntimeException('Invalid Node:'.$node['type']); |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | return $out; |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | $out [] = self::renderExpr($node); |
| 333 | 333 | break; |
| 334 | 334 | default: |
| 335 | - throw new \RuntimeException('Invalid Node:' . $node['type']); |
|
| 335 | + throw new \RuntimeException('Invalid Node:'.$node['type']); |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | return join('.', $out); |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | function doEval() |
| 342 | 342 | { |
| 343 | - return eval('use Seufert\Hamle; return ' . $this->toPHP() . ';'); |
|
| 343 | + return eval('use Seufert\Hamle; return '.$this->toPHP().';'); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | static function varToCode($var) |
@@ -348,9 +348,9 @@ discard block |
||
| 348 | 348 | if (is_array($var)) { |
| 349 | 349 | $code = []; |
| 350 | 350 | foreach ($var as $key => $value) { |
| 351 | - $code[] = self::varToCode($key) . '=>' . self::varToCode($value); |
|
| 351 | + $code[] = self::varToCode($key).'=>'.self::varToCode($value); |
|
| 352 | 352 | } |
| 353 | - return 'array(' . implode(',', $code) . ')'; //remove unnecessary coma |
|
| 353 | + return 'array('.implode(',', $code).')'; //remove unnecessary coma |
|
| 354 | 354 | } |
| 355 | 355 | if (is_bool($var)) { |
| 356 | 356 | return ($var ? 'TRUE' : 'FALSE'); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | if ($var instanceof Text) { |
| 362 | 362 | return $var->toPHP(); |
| 363 | 363 | } |
| 364 | - return "'" . str_replace(['$', "'"], ['$', "\\'"], $var) . "'"; |
|
| 364 | + return "'".str_replace(['$', "'"], ['$', "\\'"], $var)."'"; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
@@ -126,10 +126,13 @@ discard block |
||
| 126 | 126 | $args = join(',', array_map(function($v) { |
| 127 | 127 | if(is_array($v) && $v['type'] ?? false === 'expr') { |
| 128 | 128 | return self::renderExpr($v); |
| 129 | - } else |
|
| 130 | - return self::varToCode($v); |
|
| 129 | + } else { |
|
| 130 | + return self::varToCode($v); |
|
| 131 | + } |
|
| 131 | 132 | } , $filter['args'])); |
| 132 | - if(strlen($args)) $args = ','.$args; |
|
| 133 | + if(strlen($args)) { |
|
| 134 | + $args = ','.$args; |
|
| 135 | + } |
|
| 133 | 136 | $o = "$func($o" . $args . ")"; |
| 134 | 137 | if($filter['chain'] ?? false) { |
| 135 | 138 | $o = self::addFilter($o, $filter['chain']); |
@@ -202,8 +205,9 @@ discard block |
||
| 202 | 205 | self::varToCode($limit), |
| 203 | 206 | self::varToCode($offset) |
| 204 | 207 | ]; |
| 205 | - if ($addGroup) |
|
| 206 | - $opt[] = self::varToCode($group); |
|
| 208 | + if ($addGroup) { |
|
| 209 | + $opt[] = self::varToCode($group); |
|
| 210 | + } |
|
| 207 | 211 | return join(',', $opt); |
| 208 | 212 | } |
| 209 | 213 | |
@@ -239,10 +243,12 @@ discard block |
||
| 239 | 243 | $id = null; |
| 240 | 244 | $type = []; |
| 241 | 245 | foreach ($n['query'] ?? [] as $q) { |
| 242 | - if ($q['q'] === 'id') |
|
| 243 | - $id = $q['id'] ?? null; |
|
| 244 | - if ($q['q'] === 'type') |
|
| 245 | - $type = $q['id']; |
|
| 246 | + if ($q['q'] === 'id') { |
|
| 247 | + $id = $q['id'] ?? null; |
|
| 248 | + } |
|
| 249 | + if ($q['q'] === 'type') { |
|
| 250 | + $type = $q['id']; |
|
| 251 | + } |
|
| 246 | 252 | } |
| 247 | 253 | if ($n['query'] === null) { |
| 248 | 254 | $o = 'Hamle\Scope::get(0)'; |
@@ -291,8 +297,9 @@ discard block |
||
| 291 | 297 | foreach ($this->tree as $node) { |
| 292 | 298 | switch ($node['type']) { |
| 293 | 299 | case 'string': |
| 294 | - if ($node['body'] !== '') |
|
| 295 | - $out .= $node['body']; |
|
| 300 | + if ($node['body'] !== '') { |
|
| 301 | + $out .= $node['body']; |
|
| 302 | + } |
|
| 296 | 303 | break; |
| 297 | 304 | case 'scopeName': |
| 298 | 305 | $out .= '<?=' . self::renderScopeName($node) . '?>'; |
@@ -322,8 +329,9 @@ discard block |
||
| 322 | 329 | foreach ($this->tree as $node) { |
| 323 | 330 | switch ($node['type']) { |
| 324 | 331 | case 'string': |
| 325 | - if ($node['body'] !== '') |
|
| 326 | - $out[] = self::varToCode($node['body']); |
|
| 332 | + if ($node['body'] !== '') { |
|
| 333 | + $out[] = self::varToCode($node['body']); |
|
| 334 | + } |
|
| 327 | 335 | break; |
| 328 | 336 | case 'scopeThis': |
| 329 | 337 | $out[] = self::renderScopeThis($node); |
@@ -47,13 +47,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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) { |
@@ -82,21 +82,23 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -301,14 +301,14 @@ |
||
| 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); } |
@@ -67,7 +67,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -306,7 +306,9 @@ |
||
| 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; } |
@@ -47,23 +47,23 @@ discard block |
||
| 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(",",',',$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(",", ',', $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 |
||
| 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 |
||
| 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 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function toPHP(): string |
| 35 | 35 | { |
| 36 | - $o = "Hamle\\Scope::getName(" . Text::varToCode($this->name) . ")"; |
|
| 36 | + $o = "Hamle\\Scope::getName(".Text::varToCode($this->name).")"; |
|
| 37 | 37 | if ($this->immediate) { |
| 38 | 38 | $o = $this->immediate->apply($o); |
| 39 | 39 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function apply(string $out): string |
| 22 | 22 | { |
| 23 | - $o = "{$out}->hamleGet(" . Text::varToCode($this->name) . ")"; |
|
| 23 | + $o = "{$out}->hamleGet(".Text::varToCode($this->name).")"; |
|
| 24 | 24 | if ($this->chain) { |
| 25 | 25 | $o = $this->chain->apply($o); |
| 26 | 26 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $this->chain = $chain; |
| 23 | 23 | $this->args = $args; |
| 24 | 24 | if (method_exists(Filter::class, $func)) { |
| 25 | - $this->func = Filter::class . "::" . $func; |
|
| 25 | + $this->func = Filter::class."::".$func; |
|
| 26 | 26 | } elseif ( |
| 27 | 27 | in_array($func, ["round", "strtoupper", "strtolower", "ucfirst"]) |
| 28 | 28 | ) { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $this->args |
| 49 | 49 | ); |
| 50 | 50 | array_unshift($args, $out); |
| 51 | - $o = "{$this->func}(" . join(",", $args) . ")"; |
|
| 51 | + $o = "{$this->func}(".join(",", $args).")"; |
|
| 52 | 52 | if ($this->chain) { |
| 53 | 53 | $o = $this->chain->apply($o); |
| 54 | 54 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $this->filters = $filters; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - static function for(string $rel, array $filters) |
|
| 23 | + static function for (string $rel, array $filters) |
|
| 24 | 24 | { |
| 25 | 25 | return new self( |
| 26 | 26 | $rel === ">" ? Hamle::REL_CHILD : Hamle::REL_PARENT, |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | public function apply(string $s): string |
| 32 | 32 | { |
| 33 | 33 | $s = |
| 34 | - $s . |
|
| 35 | - "->hamleRel({$this->rel}," . |
|
| 36 | - Query::queryParams($this->filters, true) . |
|
| 34 | + $s. |
|
| 35 | + "->hamleRel({$this->rel},". |
|
| 36 | + Query::queryParams($this->filters, true). |
|
| 37 | 37 | ")"; |
| 38 | 38 | if ($this->chain) { |
| 39 | 39 | $s = $this->chain->apply($s); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $o = self::queryId($this->filters); |
| 41 | 41 | } else { |
| 42 | 42 | $o = |
| 43 | - "Hamle\Run::modelTypeTags(" . self::queryParams($this->filters) . ")"; |
|
| 43 | + "Hamle\Run::modelTypeTags(".self::queryParams($this->filters).")"; |
|
| 44 | 44 | } |
| 45 | 45 | if ($this->immediate) { |
| 46 | 46 | $o = $this->immediate->apply($o); |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | ]; |
| 128 | 128 | if (!$type || $type === "*") { |
| 129 | 129 | $opt[0] = Text::varToCode($id); |
| 130 | - return "Hamle\Run::modelId(" . join(",", $opt) . ")"; |
|
| 130 | + return "Hamle\Run::modelId(".join(",", $opt).")"; |
|
| 131 | 131 | } |
| 132 | - return "Hamle\Run::modelTypeId(" . join(",", $opt) . ")"; |
|
| 132 | + return "Hamle\Run::modelTypeId(".join(",", $opt).")"; |
|
| 133 | 133 | } |
| 134 | 134 | } |