@@ -76,8 +76,11 @@ discard block |
||
76 | 76 | $i += $this->doStrings($tokens, $char, $i); |
77 | 77 | $i += $this->doBrackets($tokens, $char, $i); |
78 | 78 | } |
79 | - if ($returnObj) return new Tokens($tokens); |
|
80 | - else return $tokens; |
|
79 | + if ($returnObj) { |
|
80 | + return new Tokens($tokens); |
|
81 | + } else { |
|
82 | + return $tokens; |
|
83 | + } |
|
81 | 84 | } |
82 | 85 | |
83 | 86 | private function doSimpleTokens(&$tokens, $char) { |
@@ -107,10 +110,15 @@ discard block |
||
107 | 110 | } |
108 | 111 | |
109 | 112 | private function processLiterals(&$tokens, $name) { |
110 | - if (is_numeric($name)) $tokens[] = ['type' => self::NUMERIC, 'value' => $name]; |
|
111 | - else if ($name == 'true') $tokens[] = ['type' => self::BOOL, 'value' => true]; |
|
112 | - else if ($name == 'false') $tokens[] = ['type' => self::BOOL, 'value' => false]; |
|
113 | - else $tokens[] = ['type' => self::NAME, 'value' => $name]; |
|
113 | + if (is_numeric($name)) { |
|
114 | + $tokens[] = ['type' => self::NUMERIC, 'value' => $name]; |
|
115 | + } else if ($name == 'true') { |
|
116 | + $tokens[] = ['type' => self::BOOL, 'value' => true]; |
|
117 | + } else if ($name == 'false') { |
|
118 | + $tokens[] = ['type' => self::BOOL, 'value' => false]; |
|
119 | + } else { |
|
120 | + $tokens[] = ['type' => self::NAME, 'value' => $name]; |
|
121 | + } |
|
114 | 122 | } |
115 | 123 | |
116 | 124 | private function doBrackets(&$tokens, $char, $i) { |
@@ -144,7 +152,9 @@ discard block |
||
144 | 152 | private function extractString($pos) { |
145 | 153 | $char = $this->str[$pos]; |
146 | 154 | $end = strpos($this->str, $char, $pos+1); |
147 | - while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1); |
|
155 | + while ($end !== false && $this->str[$end-1] == '\\') { |
|
156 | + $end = strpos($this->str, $char, $end+1); |
|
157 | + } |
|
148 | 158 | |
149 | 159 | return substr($this->str, $pos+1, $end-$pos-1); |
150 | 160 | } |
@@ -153,18 +163,26 @@ discard block |
||
153 | 163 | $close = strpos($this->str, $closeBracket, $open); |
154 | 164 | |
155 | 165 | $cPos = $open+1; |
156 | - while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1); |
|
166 | + while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) { |
|
167 | + $close = strpos($this->str, $closeBracket, $close+1); |
|
168 | + } |
|
157 | 169 | return substr($this->str, $open+1, $close-$open-1); |
158 | 170 | } |
159 | 171 | |
160 | 172 | private function identifyChar($chr) { |
161 | - if (isset($this->chars[$chr])) return $this->chars[$chr]; |
|
162 | - else return self::NAME; |
|
173 | + if (isset($this->chars[$chr])) { |
|
174 | + return $this->chars[$chr]; |
|
175 | + } else { |
|
176 | + return self::NAME; |
|
177 | + } |
|
163 | 178 | } |
164 | 179 | |
165 | 180 | private function getChar($num) { |
166 | 181 | $chars = array_reverse($this->chars); |
167 | - if (isset($chars[$num])) return $chars[$num]; |
|
168 | - else return false; |
|
182 | + if (isset($chars[$num])) { |
|
183 | + return $chars[$num]; |
|
184 | + } else { |
|
185 | + return false; |
|
186 | + } |
|
169 | 187 | } |
170 | 188 | } |