@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | $builder->setSource($this->_file, $this->_line); |
| 117 | 117 | $builder->onDocumentStart(); |
| 118 | 118 | |
| 119 | - $i=0; |
|
| 119 | + $i = 0; |
|
| 120 | 120 | // remove BOM (UTF-8 byte order mark)... |
| 121 | 121 | if (substr($src, 0, 3) === self::BOM_STR) { |
| 122 | - $i=3; |
|
| 122 | + $i = 3; |
|
| 123 | 123 | } |
| 124 | - for (; $i<$len; $i++) { |
|
| 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 | 127 | if ($c === "\n") $builder->setSource($this->_file, ++$this->_line); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | if ($c !== '>') { |
| 202 | 202 | $this->raiseError("Expected '/>', but found '/$c' inside tag < $tagname >"); |
| 203 | 203 | } |
| 204 | - $mark = $i+1; // mark text start |
|
| 204 | + $mark = $i+1; // mark text start |
|
| 205 | 205 | $state = self::ST_TEXT; |
| 206 | 206 | $builder->onElementStart($tagname, $attributes); |
| 207 | 207 | $builder->onElementClose($tagname); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | case self::ST_TAG_BETWEEN_ATTRIBUTE: |
| 211 | 211 | case self::ST_TAG_ATTRIBUTES: |
| 212 | 212 | if ($c === '>') { |
| 213 | - $mark = $i+1; // mark text start |
|
| 213 | + $mark = $i+1; // mark text start |
|
| 214 | 214 | $state = self::ST_TEXT; |
| 215 | 215 | $builder->onElementStart($tagname, $attributes); |
| 216 | 216 | } elseif ($c === '/') { |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | case self::ST_COMMENT: |
| 227 | 227 | if ($c === '>' && $i > $mark+4 && substr($src, $i-2, 2) === '--') { |
| 228 | 228 | |
| 229 | - if (preg_match('/^-|--|-$/', substr($src, $mark +4, $i-$mark+1 -7))) { |
|
| 229 | + if (preg_match('/^-|--|-$/', substr($src, $mark+4, $i-$mark+1-7))) { |
|
| 230 | 230 | $this->raiseError("Ill-formed comment. XML comments are not allowed to contain '--' or start/end with '-': ".substr($src, $mark+4, $i-$mark+1-7)); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | if ($c === '=') $state = self::ST_ATTR_VALUE; |
| 291 | 291 | else /* white char */ $state = self::ST_ATTR_EQ; |
| 292 | - } elseif ($c === '/' || $c==='>') { |
|
| 292 | + } elseif ($c === '/' || $c === '>') { |
|
| 293 | 293 | $attribute = substr($src, $mark, $i-$mark); |
| 294 | 294 | if (!$this->isValidQName($attribute)) { |
| 295 | 295 | $this->raiseError("Invalid attribute name '$attribute'"); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | // PHPTAL's code generator assumes input is escaped for double-quoted strings. Single-quoted attributes need to be converted. |
| 325 | 325 | // FIXME: it should be escaped at later stage. |
| 326 | - $attributes[$attribute] = str_replace('"',""", $attributes[$attribute]); |
|
| 326 | + $attributes[$attribute] = str_replace('"', """, $attributes[$attribute]); |
|
| 327 | 327 | $state = self::ST_TAG_BETWEEN_ATTRIBUTE; |
| 328 | 328 | } |
| 329 | 329 | break; |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | $builder->onDocumentEnd(); |
| 349 | 349 | } |
| 350 | - catch(PHPTAL_TemplateException $e) |
|
| 350 | + catch (PHPTAL_TemplateException $e) |
|
| 351 | 351 | { |
| 352 | 352 | $e->hintSrcPosition($this->_file, $this->_line); |
| 353 | 353 | throw $e; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | // $match expression below somehow triggers quite deep recurrency and stack overflow in preg |
| 371 | 371 | // to avoid this, check string bit by bit, omitting ASCII fragments. |
| 372 | 372 | if (strlen($str) > 200) { |
| 373 | - $chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/',$str,null,PREG_SPLIT_NO_EMPTY); |
|
| 373 | + $chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/', $str, null, PREG_SPLIT_NO_EMPTY); |
|
| 374 | 374 | foreach ($chunks as $chunk) { |
| 375 | 375 | if (strlen($chunk) < 200) { |
| 376 | 376 | $this->checkEncoding($chunk); |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | . '|\xED[\x80-\x9F][\x80-\xBF]' // excluding surrogates |
| 390 | 390 | . '|\xF0[\x90-\xBF][\x80-\xBF]{2}' // planes 1-3 |
| 391 | 391 | . '|[\xF1-\xF3][\x80-\xBF]{3}' // planes 4-15 |
| 392 | - . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16 |
|
| 392 | + . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16 |
|
| 393 | 393 | |
| 394 | - if (!preg_match('/^(?:(?>'.$match.'))+$/s',$str)) { |
|
| 395 | - $res = preg_split('/((?>'.$match.')+)/s',$str,null,PREG_SPLIT_DELIM_CAPTURE); |
|
| 396 | - for($i=0; $i < count($res); $i+=2) |
|
| 394 | + if (!preg_match('/^(?:(?>'.$match.'))+$/s', $str)) { |
|
| 395 | + $res = preg_split('/((?>'.$match.')+)/s', $str, null, PREG_SPLIT_DELIM_CAPTURE); |
|
| 396 | + for ($i = 0; $i < count($res); $i += 2) |
|
| 397 | 397 | { |
| 398 | 398 | $res[$i] = self::convertBytesToEntities(array(1=>$res[$i])); |
| 399 | 399 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | { |
| 427 | 427 | $m = $m[1]; |
| 428 | 428 | $out = ""; |
| 429 | - for($i=0; $i < strlen($m); $i++) |
|
| 429 | + for ($i = 0; $i < strlen($m); $i++) |
|
| 430 | 430 | { |
| 431 | 431 | $out .= '&#X'.strtoupper(dechex(ord($m[$i]))).';'; |
| 432 | 432 | } |