@@ -45,7 +45,7 @@ |
||
| 45 | 45 | |
| 46 | 46 | static function decodeClassId($s) { |
| 47 | 47 | $out = $m = array(); |
| 48 | - if(preg_match('/^[a-zA-Z0-9\_]+/', $s, $m)) |
|
| 48 | + if (preg_match('/^[a-zA-Z0-9\_]+/', $s, $m)) |
|
| 49 | 49 | $out['type'] = $m[0]; |
| 50 | 50 | preg_match_all('/[#\.][a-zA-Z0-9\-\_]+/m', $s, $m); |
| 51 | 51 | if (isset($m[0])) foreach ($m[0] as $ss) { |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function __construct($s) { |
| 52 | 52 | $m = array(); |
| 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 | if (trim($m[2])) |
| 56 | 56 | $this->sub = new FuncSub($m[2]); |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | $rand = false; |
| 94 | 94 | if (preg_match_all('/\\^(-?)([a-zA-Z0-9_]*)/', $s, $m)) { |
| 95 | - foreach($m[0] as $k=>$mv) |
|
| 95 | + foreach ($m[0] as $k=>$mv) |
|
| 96 | 96 | if ($m[2][$k]) { |
| 97 | - $dir = $m[1][$k] == "-"?Hamle\Hamle::SORT_DESCENDING:Hamle\Hamle::SORT_ASCENDING; |
|
| 97 | + $dir = $m[1][$k] == "-" ?Hamle\Hamle::SORT_DESCENDING : Hamle\Hamle::SORT_ASCENDING; |
|
| 98 | 98 | $att['sort'][$m[2][$k]] = $dir; |
| 99 | 99 | } else $rand = true; |
| 100 | 100 | } |
| 101 | - if($rand) |
|
| 101 | + if ($rand) |
|
| 102 | 102 | $att['sort'] = [""=>$att['dir'] = Hamle\Hamle::SORT_RANDOM]; |
| 103 | 103 | return $att; |
| 104 | 104 | } |
@@ -116,25 +116,25 @@ discard block |
||
| 116 | 116 | * @return string PHP Code |
| 117 | 117 | */ |
| 118 | 118 | public function toPHP() { |
| 119 | - $sub = $this->sub ? "->" . $this->sub->toPHP() : ""; |
|
| 120 | - if($this->scope instanceof Scope) { |
|
| 121 | - return $this->scope->toPHP() . $sub; |
|
| 122 | - } elseif($this->scope === true) { |
|
| 119 | + $sub = $this->sub ? "->".$this->sub->toPHP() : ""; |
|
| 120 | + if ($this->scope instanceof Scope) { |
|
| 121 | + return $this->scope->toPHP().$sub; |
|
| 122 | + } elseif ($this->scope === true) { |
|
| 123 | 123 | return "Hamle\\Scope::get(0)$sub"; |
| 124 | 124 | } |
| 125 | - $limit = Text::varToCode($this->sortlimit['sort']) . "," . |
|
| 126 | - $this->sortlimit['limit'] . "," . $this->sortlimit['offset']; |
|
| 125 | + $limit = Text::varToCode($this->sortlimit['sort']).",". |
|
| 126 | + $this->sortlimit['limit'].",".$this->sortlimit['offset']; |
|
| 127 | 127 | if (count($this->filt['tag'])) |
| 128 | - return "Hamle\\Run::modelTypeTags(" . |
|
| 129 | - Text::varToCode($this->filt['tag']) . ",$limit)$sub"; |
|
| 128 | + return "Hamle\\Run::modelTypeTags(". |
|
| 129 | + Text::varToCode($this->filt['tag']).",$limit)$sub"; |
|
| 130 | 130 | if (count($this->filt['id'])) |
| 131 | 131 | if (isset($this->filt['id']['*']) && count($this->filt['id']['*']) == 1) |
| 132 | - return "Hamle\\Run::modelId(" . |
|
| 133 | - Text::varToCode(current($this->filt['id']['*'])) . |
|
| 132 | + return "Hamle\\Run::modelId(". |
|
| 133 | + Text::varToCode(current($this->filt['id']['*'])). |
|
| 134 | 134 | ",$limit)$sub"; |
| 135 | 135 | else |
| 136 | - return "Hamle\\Run::modelTypeId(" . |
|
| 137 | - Text::varToCode($this->filt['id']) . ",$limit)$sub"; |
|
| 136 | + return "Hamle\\Run::modelTypeId(". |
|
| 137 | + Text::varToCode($this->filt['id']).",$limit)$sub"; |
|
| 138 | 138 | return ""; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @return Model |
| 144 | 144 | */ |
| 145 | 145 | public function getOrCreateModel(Model $parent = null) { |
| 146 | - if($this->scope instanceof Scope) { |
|
| 146 | + if ($this->scope instanceof Scope) { |
|
| 147 | 147 | $parent = $this->scope->getOrCreateModel(); |
| 148 | 148 | } elseif ($this->scope === true) |
| 149 | 149 | $parent = \Seufert\Hamle\Scope::get(0); |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | $this->sortlimit['limit'], |
| 170 | 170 | $this->sortlimit['offset'] |
| 171 | 171 | ); |
| 172 | - if($this->sub) |
|
| 172 | + if ($this->sub) |
|
| 173 | 173 | return $this->sub->getOrCreateModel($parent)->current(); |
| 174 | - if(!$parent) |
|
| 174 | + if (!$parent) |
|
| 175 | 175 | throw new \RuntimeException('Unable to create model with no relation'); |
| 176 | 176 | return $parent->current(); |
| 177 | 177 | } |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | protected $filter; |
| 38 | 38 | |
| 39 | 39 | function __construct($s) { |
| 40 | - if(FALSE !== $pos = strpos($s,'|')) { |
|
| 41 | - $this->filter = new Filter(substr($s, $pos+1), $this); |
|
| 42 | - $s = substr($s,0,$pos); |
|
| 40 | + if (FALSE !== $pos = strpos($s, '|')) { |
|
| 41 | + $this->filter = new Filter(substr($s, $pos + 1), $this); |
|
| 42 | + $s = substr($s, 0, $pos); |
|
| 43 | 43 | } |
| 44 | 44 | $s = preg_split("/-[>!]/", $s); |
| 45 | 45 | // if(count($s) == 1) $s = explode("-!",$s[0]); |
@@ -55,27 +55,27 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | function toHTML($escape = false) { |
| 58 | - if($escape) |
|
| 59 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 60 | - return "<?=" . $this->toPHP() . "?>"; |
|
| 58 | + if ($escape) |
|
| 59 | + return "<?=htmlspecialchars(".$this->toPHP().")?>"; |
|
| 60 | + return "<?=".$this->toPHP()."?>"; |
|
| 61 | 61 | } |
| 62 | 62 | function toPHP() { |
| 63 | - return $this->filter?$this->filter->toPHP():$this->toPHPVar(); |
|
| 63 | + return $this->filter ? $this->filter->toPHP() : $this->toPHPVar(); |
|
| 64 | 64 | } |
| 65 | 65 | function toPHPVar() { |
| 66 | 66 | if ($this->sel) { |
| 67 | 67 | $sel = array(); |
| 68 | 68 | foreach ($this->sel as $s) |
| 69 | 69 | $sel[] = "hamleGet('$s')"; |
| 70 | - return $this->func->toPHP() . "->" . implode('->', $sel); |
|
| 70 | + return $this->func->toPHP()."->".implode('->', $sel); |
|
| 71 | 71 | } else |
| 72 | 72 | return $this->func->toPHP(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | function getOrCreateModel(Model $parent = null) { |
| 76 | - if($this->func instanceof Text\Scope) |
|
| 76 | + if ($this->func instanceof Text\Scope) |
|
| 77 | 77 | return $this->func->getOrCreateModel($parent); |
| 78 | - if($this->func instanceof Text\Func) |
|
| 78 | + if ($this->func instanceof Text\Func) |
|
| 79 | 79 | return $this->func->getOrCreateModel($parent); |
| 80 | 80 | throw new RuntimeException('Unsupported func type encountered:'.get_class($this->func)); |
| 81 | 81 | } |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | * @return WriteModel |
| 86 | 86 | */ |
| 87 | 87 | function setValue($value) { |
| 88 | - if(!$this->sel || count($this->sel) != 1) |
|
| 88 | + if (!$this->sel || count($this->sel) != 1) |
|
| 89 | 89 | throw new RuntimeException('Can only set values, when one var name is present'); |
| 90 | 90 | $model = $this->getOrCreateModel(); |
| 91 | - if(!$model instanceof WriteModel) |
|
| 91 | + if (!$model instanceof WriteModel) |
|
| 92 | 92 | throw new RuntimeException('Can only set values on WriteModel, got '.get_class($model)); |
| 93 | 93 | $model->hamleSet($this->sel[0], $value); |
| 94 | 94 | return $model; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | self::$namedScopes[$name] = $model; |
| 28 | 28 | else |
| 29 | 29 | self::$scopes[] = $model; |
| 30 | - if(self::$scopeHook) {
|
|
| 30 | + if (self::$scopeHook) {
|
|
| 31 | 31 | (self::$scopeHook)($model); |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | self::$namedScopes[$name]->rewind(); |
| 74 | 74 | return self::$namedScopes[$name]; |
| 75 | 75 | } else |
| 76 | - if(self::$returnZeroOnNoScope) |
|
| 76 | + if (self::$returnZeroOnNoScope) |
|
| 77 | 77 | return new Model\Zero(); |
| 78 | 78 | throw new RunTime("Unable to find scope ($name)");
|
| 79 | 79 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $i = self::indentLevel($indent); |
| 157 | 157 | unset($m[0]); |
| 158 | 158 | switch (strlen($code) ? $code[0] : ($textcode ? $textcode : "")) { |
| 159 | - case "|": //Control Tag |
|
| 159 | + case "|" : //Control Tag |
|
| 160 | 160 | if ($code == "|snippet") |
| 161 | 161 | $hTag = new Tag\Snippet($text); |
| 162 | 162 | elseif ($code == "|form") |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | break; |
| 197 | 197 | default: |
| 198 | 198 | $attr = array(); |
| 199 | - if(isset($params[0]) && $params[0] == "[") { |
|
| 199 | + if (isset($params[0]) && $params[0] == "[") { |
|
| 200 | 200 | $param = substr($params, 1, -1); |
| 201 | 201 | $param = str_replace(['+', '\\&'], ['%2B', '%26'], $param); |
| 202 | 202 | // parse_str($param, $attr); |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | if ($s[0] == ".") $class[] = substr($s, 1); |
| 210 | 210 | if ($s[0] == "!") $ref = substr($s, 1); |
| 211 | 211 | } |
| 212 | - if($ref) |
|
| 212 | + if ($ref) |
|
| 213 | 213 | $hTag = new Tag\DynHtml($tag, $class, $attr, $id, $ref); |
| 214 | 214 | else |
| 215 | 215 | $hTag = new Tag\Html($tag, $class, $attr, $id); |
@@ -222,16 +222,16 @@ discard block |
||
| 222 | 222 | else |
| 223 | 223 | $this->root[] = $hTag; |
| 224 | 224 | } else |
| 225 | - throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/" . preg_last_error()); |
|
| 225 | + throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/".preg_last_error()); |
|
| 226 | 226 | $this->lineNo++; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | function parseQueryString($qs) { |
| 231 | 231 | $out = []; |
| 232 | - foreach(explode('&',$qs) as $s) { |
|
| 233 | - $kv = explode('=',$s,2); |
|
| 234 | - $out[urldecode($kv[0])] = isset($kv[1])?urldecode($kv[1]):null; |
|
| 232 | + foreach (explode('&', $qs) as $s) { |
|
| 233 | + $kv = explode('=', $s, 2); |
|
| 234 | + $out[urldecode($kv[0])] = isset($kv[1]) ?urldecode($kv[1]) : null; |
|
| 235 | 235 | } |
| 236 | 236 | return $out; |
| 237 | 237 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $m = array(); |
| 250 | 250 | while ($this->lineNo + 1 < $this->lineCount && |
| 251 | 251 | (!trim($this->lines[$this->lineNo + 1]) || |
| 252 | - preg_match('/^(\s){' . $indent . '}((\s)+[^\s].*)$/', |
|
| 252 | + preg_match('/^(\s){'.$indent.'}((\s)+[^\s].*)$/', |
|
| 253 | 253 | $this->lines[$this->lineNo + 1], $m))) { |
| 254 | 254 | if (trim($this->lines[$this->lineNo + 1])) |
| 255 | 255 | $out[] = $m[2]; |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | function getValue() { |
| 114 | 114 | if (!is_null($this->setValue)) return $this->setValue; |
| 115 | - if (isset($_REQUEST[$this->form . "_" . $this->name])) { |
|
| 116 | - return $_REQUEST[$this->form . "_" . $this->name]; |
|
| 115 | + if (isset($_REQUEST[$this->form."_".$this->name])) { |
|
| 116 | + return $_REQUEST[$this->form."_".$this->name]; |
|
| 117 | 117 | } |
| 118 | 118 | return $this->opt['default']; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | function getInputAttStatic(&$atts, &$type, &$content) { |
| 122 | - $atts['id'] = $atts['name'] = $this->form . "_" . $this->name; |
|
| 122 | + $atts['id'] = $atts['name'] = $this->form."_".$this->name; |
|
| 123 | 123 | $atts['type'] = "text"; |
| 124 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
| 124 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | function getInputAttDynamic(&$atts, &$type, &$content) { |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | function getLabelAttStatic(&$atts, &$type, &$content) { |
| 142 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
| 143 | - $atts["for"] = $this->form . "_" . $this->name; |
|
| 142 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
| 143 | + $atts["for"] = $this->form."_".$this->name; |
|
| 144 | 144 | $content = array($this->opt['label']); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function getHintAttStatic(&$atts, &$type, &$content) { |
| 151 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
| 151 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
| 152 | 152 | $atts['class'][] = "hamleFormHint"; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -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 | /** |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | public function toPHP():string { |
| 33 | - $o = "Hamle\\Scope::getName(" . Text::varToCode($this->name) . ")"; |
|
| 33 | + $o = "Hamle\\Scope::getName(".Text::varToCode($this->name).")"; |
|
| 34 | 34 | if ($this->immediate) $o = $this->immediate->apply($o); |
| 35 | - if($this->chain) $o = $this->chain->apply($o); |
|
| 35 | + if ($this->chain) $o = $this->chain->apply($o); |
|
| 36 | 36 | return $o; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function apply(string $out): string |
| 25 | 25 | { |
| 26 | - $o = "{$out}->hamleGet(" . Text::varToCode($this->name) . ")"; |
|
| 27 | - if($this->chain) |
|
| 26 | + $o = "{$out}->hamleGet(".Text::varToCode($this->name).")"; |
|
| 27 | + if ($this->chain) |
|
| 28 | 28 | $o = $this->chain->apply($o); |
| 29 | 29 | return $o; |
| 30 | 30 | } |