@@ -76,10 +76,11 @@ |
||
| 76 | 76 | |
| 77 | 77 | protected function doEchoAttribute(PHPTAL_Php_CodeWriter $codewriter, $code) |
| 78 | 78 | { |
| 79 | - if ($this->_echoType === self::ECHO_TEXT) |
|
| 80 | - $codewriter->doEcho($code); |
|
| 81 | - else |
|
| 82 | - $codewriter->doEchoRaw($code); |
|
| 79 | + if ($this->_echoType === self::ECHO_TEXT) { |
|
| 80 | + $codewriter->doEcho($code); |
|
| 81 | + } else { |
|
| 82 | + $codewriter->doEchoRaw($code); |
|
| 83 | + } |
|
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | /** |
@@ -82,10 +82,12 @@ |
||
| 82 | 82 | $this->reader->talesChainPart($this, $exp, $lastkey === $key); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ($this->state == self::CHAIN_BREAK) |
|
| 86 | - break; |
|
| 87 | - if ($this->state == self::CHAIN_CONT) |
|
| 88 | - continue; |
|
| 85 | + if ($this->state == self::CHAIN_BREAK) { |
|
| 86 | + break; |
|
| 87 | + } |
|
| 88 | + if ($this->state == self::CHAIN_CONT) { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 89 | 91 | } |
| 90 | 92 | |
| 91 | 93 | $this->codewriter->doEnd('if'); |
@@ -42,7 +42,9 @@ |
||
| 42 | 42 | |
| 43 | 43 | function skipSpace() |
| 44 | 44 | { |
| 45 | - while ($this->current_token === 'SPACE') $this->nextToken(); |
|
| 45 | + while ($this->current_token === 'SPACE') { |
|
| 46 | + $this->nextToken(); |
|
| 47 | + } |
|
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | function nextToken() |
@@ -124,7 +124,9 @@ discard block |
||
| 124 | 124 | for (; $i<$len; $i++) { |
| 125 | 125 | $c = $src[$i]; // Change to substr($src, $i, 1); if you want to use mb_string.func_overload |
| 126 | 126 | |
| 127 | - if ($c === "\n") $builder->setSource($this->_file, ++$this->_line); |
|
| 127 | + if ($c === "\n") { |
|
| 128 | + $builder->setSource($this->_file, ++$this->_line); |
|
| 129 | + } |
|
| 128 | 130 | |
| 129 | 131 | switch ($state) { |
| 130 | 132 | case self::ST_ROOT: |
@@ -174,7 +176,9 @@ discard block |
||
| 174 | 176 | case self::ST_TAG_NAME: |
| 175 | 177 | if (self::isWhiteChar($c) || $c === '/' || $c === '>') { |
| 176 | 178 | $tagname = substr($src, $mark, $i-$mark); |
| 177 | - if (!$this->isValidQName($tagname)) $this->raiseError("Invalid tag name '$tagname'"); |
|
| 179 | + if (!$this->isValidQName($tagname)) { |
|
| 180 | + $this->raiseError("Invalid tag name '$tagname'"); |
|
| 181 | + } |
|
| 178 | 182 | |
| 179 | 183 | if ($c === '/') { |
| 180 | 184 | $state = self::ST_TAG_SINGLE; |
@@ -220,7 +224,9 @@ discard block |
||
| 220 | 224 | } elseif ($state === self::ST_TAG_ATTRIBUTES && $this->isValidQName($c)) { |
| 221 | 225 | $mark = $i; // mark attribute key start |
| 222 | 226 | $state = self::ST_ATTR_KEY; |
| 223 | - } else $this->raiseError("Unexpected character '$c' between attributes of < $tagname >"); |
|
| 227 | + } else { |
|
| 228 | + $this->raiseError("Unexpected character '$c' between attributes of < $tagname >"); |
|
| 229 | + } |
|
| 224 | 230 | break; |
| 225 | 231 | |
| 226 | 232 | case self::ST_COMMENT: |
@@ -287,8 +293,11 @@ discard block |
||
| 287 | 293 | $this->raiseError("Attribute $attribute in < $tagname > is defined more than once"); |
| 288 | 294 | } |
| 289 | 295 | |
| 290 | - if ($c === '=') $state = self::ST_ATTR_VALUE; |
|
| 291 | - else /* white char */ $state = self::ST_ATTR_EQ; |
|
| 296 | + if ($c === '=') { |
|
| 297 | + $state = self::ST_ATTR_VALUE; |
|
| 298 | + } else { |
|
| 299 | + /* white char */ $state = self::ST_ATTR_EQ; |
|
| 300 | + } |
|
| 292 | 301 | } elseif ($c === '/' || $c==='>') { |
| 293 | 302 | $attribute = substr($src, $mark, $i-$mark); |
| 294 | 303 | if (!$this->isValidQName($attribute)) { |
@@ -330,11 +339,15 @@ discard block |
||
| 330 | 339 | } |
| 331 | 340 | } |
| 332 | 341 | |
| 333 | - if ($state === self::ST_TEXT) // allows text past root node, which is in violation of XML spec |
|
| 342 | + if ($state === self::ST_TEXT) { |
|
| 343 | + // allows text past root node, which is in violation of XML spec |
|
| 334 | 344 | { |
| 335 | 345 | if ($i > $mark) { |
| 336 | 346 | $text = substr($src, $mark, $i-$mark); |
| 337 | - if (!ctype_space($text)) $this->raiseError("Characters found after end of the root element (wrap document in < tal:block > to avoid this error)"); |
|
| 347 | + } |
|
| 348 | + if (!ctype_space($text)) { |
|
| 349 | + $this->raiseError("Characters found after end of the root element (wrap document in < tal:block > to avoid this error)"); |
|
| 350 | + } |
|
| 338 | 351 | } |
| 339 | 352 | } else { |
| 340 | 353 | if ($state === self::ST_ROOT) { |
@@ -346,8 +359,7 @@ discard block |
||
| 346 | 359 | } |
| 347 | 360 | |
| 348 | 361 | $builder->onDocumentEnd(); |
| 349 | - } |
|
| 350 | - catch(PHPTAL_TemplateException $e) |
|
| 362 | + } catch(PHPTAL_TemplateException $e) |
|
| 351 | 363 | { |
| 352 | 364 | $e->hintSrcPosition($this->_file, $this->_line); |
| 353 | 365 | throw $e; |
@@ -363,7 +375,9 @@ discard block |
||
| 363 | 375 | |
| 364 | 376 | private function checkEncoding($str) |
| 365 | 377 | { |
| 366 | - if ($str === '') return ''; |
|
| 378 | + if ($str === '') { |
|
| 379 | + return ''; |
|
| 380 | + } |
|
| 367 | 381 | |
| 368 | 382 | if ($this->input_encoding === 'UTF-8') { |
| 369 | 383 | |
@@ -445,7 +459,9 @@ discard block |
||
| 445 | 459 | */ |
| 446 | 460 | $str = preg_replace_callback('/<\?(php|=)(.*?)\?>/', static function ($m) { |
| 447 | 461 | list(, $type, $code) = $m; |
| 448 | - if ($type === '=') $code = 'echo '.$code; |
|
| 462 | + if ($type === '=') { |
|
| 463 | + $code = 'echo '.$code; |
|
| 464 | + } |
|
| 449 | 465 | return '${structure phptal-internal-php-block:'.rawurlencode($code).'}'; |
| 450 | 466 | }, $str); |
| 451 | 467 | |