@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | protected function scriptCallback($matches) |
32 | 32 | { |
33 | - return $matches[1] . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8') . $matches[3]; |
|
33 | + return $matches[ 1 ].htmlspecialchars($matches[ 2 ], ENT_COMPAT, 'UTF-8').$matches[ 3 ]; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $e = false; |
87 | 87 | if ($config->get('Core.CollectErrors')) { |
88 | - $e =& $context->get('ErrorCollector'); |
|
88 | + $e = & $context->get('ErrorCollector'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // for testing synchronization |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | if ($maintain_line_numbers) { |
100 | 100 | // $rcursor, however, is always at the start of a token. |
101 | - $rcursor = $cursor - (int)$inside_tag; |
|
101 | + $rcursor = $cursor - (int) $inside_tag; |
|
102 | 102 | |
103 | 103 | // Column number is cheap, so we calculate it every round. |
104 | 104 | // We're interested at the *end* of the newline string, so |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $token->rawPosition($current_line, $current_col); |
142 | 142 | $current_line += $this->substrCount($html, $nl, $cursor, $position_next_lt - $cursor); |
143 | 143 | } |
144 | - $array[] = $token; |
|
144 | + $array[ ] = $token; |
|
145 | 145 | $cursor = $position_next_lt + 1; |
146 | 146 | $inside_tag = true; |
147 | 147 | continue; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | if ($maintain_line_numbers) { |
165 | 165 | $token->rawPosition($current_line, $current_col); |
166 | 166 | } |
167 | - $array[] = $token; |
|
167 | + $array[ ] = $token; |
|
168 | 168 | break; |
169 | 169 | } elseif ($inside_tag && $position_next_gt !== false) { |
170 | 170 | // We are in tag and it is well formed |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $token->rawPosition($current_line, $current_col); |
217 | 217 | $current_line += $this->substrCount($html, $nl, $cursor, $strlen_segment); |
218 | 218 | } |
219 | - $array[] = $token; |
|
219 | + $array[ ] = $token; |
|
220 | 220 | $cursor = $end ? $position_comment_end : $position_comment_end + 3; |
221 | 221 | $inside_tag = false; |
222 | 222 | continue; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $token->rawPosition($current_line, $current_col); |
232 | 232 | $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); |
233 | 233 | } |
234 | - $array[] = $token; |
|
234 | + $array[ ] = $token; |
|
235 | 235 | $inside_tag = false; |
236 | 236 | $cursor = $position_next_gt + 1; |
237 | 237 | continue; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | // Check leading character is alnum, if not, we may |
241 | 241 | // have accidently grabbed an emoticon. Translate into |
242 | 242 | // text and go our merry way |
243 | - if (!ctype_alpha($segment[0])) { |
|
243 | + if (!ctype_alpha($segment[ 0 ])) { |
|
244 | 244 | // XML: $segment[0] !== '_' && $segment[0] !== ':' |
245 | 245 | if ($e) { |
246 | 246 | $e->send(E_NOTICE, 'Lexer: Unescaped lt'); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $token->rawPosition($current_line, $current_col); |
251 | 251 | $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); |
252 | 252 | } |
253 | - $array[] = $token; |
|
253 | + $array[ ] = $token; |
|
254 | 254 | $inside_tag = false; |
255 | 255 | continue; |
256 | 256 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $token->rawPosition($current_line, $current_col); |
279 | 279 | $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); |
280 | 280 | } |
281 | - $array[] = $token; |
|
281 | + $array[ ] = $token; |
|
282 | 282 | $inside_tag = false; |
283 | 283 | $cursor = $position_next_gt + 1; |
284 | 284 | continue; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $token->rawPosition($current_line, $current_col); |
313 | 313 | $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); |
314 | 314 | } |
315 | - $array[] = $token; |
|
315 | + $array[ ] = $token; |
|
316 | 316 | $cursor = $position_next_gt + 1; |
317 | 317 | $inside_tag = false; |
318 | 318 | continue; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | } |
324 | 324 | $token = new |
325 | 325 | HTMLPurifier_Token_Text( |
326 | - '<' . |
|
326 | + '<'. |
|
327 | 327 | $this->parseData( |
328 | 328 | substr($html, $cursor) |
329 | 329 | ) |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $token->rawPosition($current_line, $current_col); |
333 | 333 | } |
334 | 334 | // no cursor scroll? Hmm... |
335 | - $array[] = $token; |
|
335 | + $array[ ] = $token; |
|
336 | 336 | break; |
337 | 337 | } |
338 | 338 | break; |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function parseAttributeString($string, $config, $context) |
377 | 377 | { |
378 | - $string = (string)$string; // quick typecast |
|
378 | + $string = (string) $string; // quick typecast |
|
379 | 379 | |
380 | 380 | if ($string == '') { |
381 | 381 | return array(); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | |
384 | 384 | $e = false; |
385 | 385 | if ($config->get('Core.CollectErrors')) { |
386 | - $e =& $context->get('ErrorCollector'); |
|
386 | + $e = & $context->get('ErrorCollector'); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | // let's see if we can abort as quickly as possible |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | if (!$quoted_value) { |
407 | 407 | return array($key => ''); |
408 | 408 | } |
409 | - $first_char = @$quoted_value[0]; |
|
410 | - $last_char = @$quoted_value[strlen($quoted_value) - 1]; |
|
409 | + $first_char = @$quoted_value[ 0 ]; |
|
410 | + $last_char = @$quoted_value[ strlen($quoted_value) - 1 ]; |
|
411 | 411 | |
412 | 412 | $same_quote = ($first_char == $last_char); |
413 | 413 | $open_quote = ($first_char == '"' || $first_char == "'"); |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $key_begin = $cursor; //we're currently at the start of the key |
455 | 455 | |
456 | 456 | // scroll past all characters that are the key (not whitespace or =) |
457 | - $cursor += strcspn($string, $this->_whitespace . '=', $cursor); |
|
457 | + $cursor += strcspn($string, $this->_whitespace.'=', $cursor); |
|
458 | 458 | |
459 | 459 | $key_end = $cursor; // now at the end of the key |
460 | 460 | |
@@ -472,13 +472,13 @@ discard block |
||
472 | 472 | $cursor += strspn($string, $this->_whitespace, $cursor); |
473 | 473 | |
474 | 474 | if ($cursor >= $size) { |
475 | - $array[$key] = $key; |
|
475 | + $array[ $key ] = $key; |
|
476 | 476 | break; |
477 | 477 | } |
478 | 478 | |
479 | 479 | // if the next character is an equal sign, we've got a regular |
480 | 480 | // pair, otherwise, it's a bool attribute |
481 | - $first_char = @$string[$cursor]; |
|
481 | + $first_char = @$string[ $cursor ]; |
|
482 | 482 | |
483 | 483 | if ($first_char == '=') { |
484 | 484 | // key="value" |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | $cursor += strspn($string, $this->_whitespace, $cursor); |
488 | 488 | |
489 | 489 | if ($cursor === false) { |
490 | - $array[$key] = ''; |
|
490 | + $array[ $key ] = ''; |
|
491 | 491 | break; |
492 | 492 | } |
493 | 493 | |
494 | 494 | // we might be in front of a quote right now |
495 | 495 | |
496 | - $char = @$string[$cursor]; |
|
496 | + $char = @$string[ $cursor ]; |
|
497 | 497 | |
498 | 498 | if ($char == '"' || $char == "'") { |
499 | 499 | // it's quoted, end bound is $char |
@@ -518,12 +518,12 @@ discard block |
||
518 | 518 | if ($value === false) { |
519 | 519 | $value = ''; |
520 | 520 | } |
521 | - $array[$key] = $this->parseData($value); |
|
521 | + $array[ $key ] = $this->parseData($value); |
|
522 | 522 | $cursor++; |
523 | 523 | } else { |
524 | 524 | // boolattr |
525 | 525 | if ($key !== '') { |
526 | - $array[$key] = $key; |
|
526 | + $array[ $key ] = $key; |
|
527 | 527 | } else { |
528 | 528 | // purely theoretical |
529 | 529 | if ($e) { |
@@ -60,47 +60,46 @@ |
||
60 | 60 | $prepend_style = ''; |
61 | 61 | |
62 | 62 | // handle color transform |
63 | - if (isset($attr['color'])) { |
|
64 | - $prepend_style .= 'color:' . $attr['color'] . ';'; |
|
65 | - unset($attr['color']); |
|
63 | + if (isset($attr[ 'color' ])) { |
|
64 | + $prepend_style .= 'color:'.$attr[ 'color' ].';'; |
|
65 | + unset($attr[ 'color' ]); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // handle face transform |
69 | - if (isset($attr['face'])) { |
|
70 | - $prepend_style .= 'font-family:' . $attr['face'] . ';'; |
|
71 | - unset($attr['face']); |
|
69 | + if (isset($attr[ 'face' ])) { |
|
70 | + $prepend_style .= 'font-family:'.$attr[ 'face' ].';'; |
|
71 | + unset($attr[ 'face' ]); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // handle size transform |
75 | - if (isset($attr['size'])) { |
|
75 | + if (isset($attr[ 'size' ])) { |
|
76 | 76 | // normalize large numbers |
77 | - if ($attr['size'] !== '') { |
|
78 | - if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { |
|
79 | - $size = (int)$attr['size']; |
|
77 | + if ($attr[ 'size' ] !== '') { |
|
78 | + if ($attr[ 'size' ]{0} == '+' || $attr[ 'size' ]{0} == '-') { |
|
79 | + $size = (int) $attr[ 'size' ]; |
|
80 | 80 | if ($size < -2) { |
81 | - $attr['size'] = '-2'; |
|
81 | + $attr[ 'size' ] = '-2'; |
|
82 | 82 | } |
83 | 83 | if ($size > 4) { |
84 | - $attr['size'] = '+4'; |
|
84 | + $attr[ 'size' ] = '+4'; |
|
85 | 85 | } |
86 | 86 | } else { |
87 | - $size = (int)$attr['size']; |
|
87 | + $size = (int) $attr[ 'size' ]; |
|
88 | 88 | if ($size > 7) { |
89 | - $attr['size'] = '7'; |
|
89 | + $attr[ 'size' ] = '7'; |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | - if (isset($this->_size_lookup[$attr['size']])) { |
|
94 | - $prepend_style .= 'font-size:' . |
|
95 | - $this->_size_lookup[$attr['size']] . ';'; |
|
93 | + if (isset($this->_size_lookup[ $attr[ 'size' ] ])) { |
|
94 | + $prepend_style .= 'font-size:'. |
|
95 | + $this->_size_lookup[ $attr[ 'size' ] ].';'; |
|
96 | 96 | } |
97 | - unset($attr['size']); |
|
97 | + unset($attr[ 'size' ]); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | if ($prepend_style) { |
101 | - $attr['style'] = isset($attr['style']) ? |
|
102 | - $prepend_style . $attr['style'] : |
|
103 | - $prepend_style; |
|
101 | + $attr[ 'style' ] = isset($attr[ 'style' ]) ? |
|
102 | + $prepend_style.$attr[ 'style' ] : $prepend_style; |
|
104 | 103 | } |
105 | 104 | |
106 | 105 | $new_tag = clone $tag; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | public function get($name) |
40 | 40 | { |
41 | 41 | if ($this->has($name)) { |
42 | - return $this->data[$name]; |
|
42 | + return $this->data[ $name ]; |
|
43 | 43 | } |
44 | 44 | // possible performance bottleneck, convert to iterative if necessary |
45 | 45 | if ($this->parent) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function set($name, $value) |
57 | 57 | { |
58 | - $this->data[$name] = $value; |
|
58 | + $this->data[ $name ] = $value; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | if ($name == null) { |
79 | 79 | $this->data = array(); |
80 | 80 | } else { |
81 | - unset($this->data[$name]); |
|
81 | + unset($this->data[ $name ]); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | foreach ($modules as $module) { |
46 | 46 | foreach ($module->content_sets as $key => $value) { |
47 | 47 | $temp = $this->convertToLookup($value); |
48 | - if (isset($this->lookup[$key])) { |
|
48 | + if (isset($this->lookup[ $key ])) { |
|
49 | 49 | // add it into the existing content set |
50 | - $this->lookup[$key] = array_merge($this->lookup[$key], $temp); |
|
50 | + $this->lookup[ $key ] = array_merge($this->lookup[ $key ], $temp); |
|
51 | 51 | } else { |
52 | - $this->lookup[$key] = $temp; |
|
52 | + $this->lookup[ $key ] = $temp; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | foreach ($this->lookup as $i => $set) { |
60 | 60 | $add = array(); |
61 | 61 | foreach ($set as $element => $x) { |
62 | - if (isset($this->lookup[$element])) { |
|
63 | - $add += $this->lookup[$element]; |
|
64 | - unset($this->lookup[$i][$element]); |
|
62 | + if (isset($this->lookup[ $element ])) { |
|
63 | + $add += $this->lookup[ $element ]; |
|
64 | + unset($this->lookup[ $i ][ $element ]); |
|
65 | 65 | } |
66 | 66 | } |
67 | - $this->lookup[$i] += $add; |
|
67 | + $this->lookup[ $i ] += $add; |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | 71 | foreach ($this->lookup as $key => $lookup) { |
72 | - $this->info[$key] = implode(' | ', array_keys($lookup)); |
|
72 | + $this->info[ $key ] = implode(' | ', array_keys($lookup)); |
|
73 | 73 | } |
74 | 74 | $this->keys = array_keys($this->info); |
75 | 75 | $this->values = array_values($this->info); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | if (is_string($content_model)) { |
90 | 90 | // Assume that $this->keys is alphanumeric |
91 | 91 | $def->content_model = preg_replace_callback( |
92 | - '/\b(' . implode('|', $this->keys) . ')\b/', |
|
92 | + '/\b('.implode('|', $this->keys).')\b/', |
|
93 | 93 | array($this, 'generateChildDefCallback'), |
94 | 94 | $content_model |
95 | 95 | ); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | public function generateChildDefCallback($matches) |
103 | 103 | { |
104 | - return $this->info[$matches[0]]; |
|
104 | + return $this->info[ $matches[ 0 ] ]; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $array = explode('|', str_replace(' ', '', $string)); |
162 | 162 | $ret = array(); |
163 | 163 | foreach ($array as $k) { |
164 | - $ret[$k] = true; |
|
164 | + $ret[ $k ] = true; |
|
165 | 165 | } |
166 | 166 | return $ret; |
167 | 167 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function toArray($t = NULL) { |
48 | 48 | $a = $this->front; |
49 | - if ($t !== NULL) $a[] = $t; |
|
50 | - for ($i = count($this->back)-1; $i >= 0; $i--) { |
|
51 | - $a[] = $this->back[$i]; |
|
49 | + if ($t !== NULL) $a[ ] = $t; |
|
50 | + for ($i = count($this->back) - 1; $i >= 0; $i--) { |
|
51 | + $a[ ] = $this->back[ $i ]; |
|
52 | 52 | } |
53 | 53 | return $a; |
54 | 54 | } |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $old = array(); |
145 | 145 | $r = $t; |
146 | 146 | for ($i = $delete; $i > 0; $i--) { |
147 | - $old[] = $r; |
|
147 | + $old[ ] = $r; |
|
148 | 148 | $r = $this->delete(); |
149 | 149 | } |
150 | 150 | // insert |
151 | - for ($i = count($replacement)-1; $i >= 0; $i--) { |
|
151 | + for ($i = count($replacement) - 1; $i >= 0; $i--) { |
|
152 | 152 | $this->insertAfter($r); |
153 | - $r = $replacement[$i]; |
|
153 | + $r = $replacement[ $i ]; |
|
154 | 154 | } |
155 | 155 | return array($old, $r); |
156 | 156 | } |
@@ -46,7 +46,9 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function toArray($t = NULL) { |
48 | 48 | $a = $this->front; |
49 | - if ($t !== NULL) $a[] = $t; |
|
49 | + if ($t !== NULL) { |
|
50 | + $a[] = $t; |
|
51 | + } |
|
50 | 52 | for ($i = count($this->back)-1; $i >= 0; $i--) { |
51 | 53 | $a[] = $this->back[$i]; |
52 | 54 | } |
@@ -59,7 +61,9 @@ discard block |
||
59 | 61 | * @return Original contents of new hole. |
60 | 62 | */ |
61 | 63 | public function next($t) { |
62 | - if ($t !== NULL) array_push($this->front, $t); |
|
64 | + if ($t !== NULL) { |
|
65 | + array_push($this->front, $t); |
|
66 | + } |
|
63 | 67 | return empty($this->back) ? NULL : array_pop($this->back); |
64 | 68 | } |
65 | 69 | |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | * @return Original contents of new hole. |
83 | 87 | */ |
84 | 88 | public function prev($t) { |
85 | - if ($t !== NULL) array_push($this->back, $t); |
|
89 | + if ($t !== NULL) { |
|
90 | + array_push($this->back, $t); |
|
91 | + } |
|
86 | 92 | return empty($this->front) ? NULL : array_pop($this->front); |
87 | 93 | } |
88 | 94 | |
@@ -108,7 +114,9 @@ discard block |
||
108 | 114 | * @param Element to insert |
109 | 115 | */ |
110 | 116 | public function insertBefore($t) { |
111 | - if ($t !== NULL) array_push($this->front, $t); |
|
117 | + if ($t !== NULL) { |
|
118 | + array_push($this->front, $t); |
|
119 | + } |
|
112 | 120 | } |
113 | 121 | |
114 | 122 | /** |
@@ -116,7 +124,9 @@ discard block |
||
116 | 124 | * @param Element to insert |
117 | 125 | */ |
118 | 126 | public function insertAfter($t) { |
119 | - if ($t !== NULL) array_push($this->back, $t); |
|
127 | + if ($t !== NULL) { |
|
128 | + array_push($this->back, $t); |
|
129 | + } |
|
120 | 130 | } |
121 | 131 | |
122 | 132 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | public function setup() |
76 | 76 | { |
77 | 77 | $this->validator = new HTMLPurifier_AttrDef_Lang(); |
78 | - $this->dir = HTMLPURIFIER_PREFIX . '/HTMLPurifier'; |
|
78 | + $this->dir = HTMLPURIFIER_PREFIX.'/HTMLPurifier'; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | if ($code == 'en') { |
108 | 108 | $lang = new HTMLPurifier_Language($config, $context); |
109 | 109 | } else { |
110 | - $class = 'HTMLPurifier_Language_' . $pcode; |
|
111 | - $file = $this->dir . '/Language/classes/' . $code . '.php'; |
|
110 | + $class = 'HTMLPurifier_Language_'.$pcode; |
|
111 | + $file = $this->dir.'/Language/classes/'.$code.'.php'; |
|
112 | 112 | if (file_exists($file) || class_exists($class, false)) { |
113 | 113 | $lang = new $class($config, $context); |
114 | 114 | } else { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | public function getFallbackFor($code) |
137 | 137 | { |
138 | 138 | $this->loadLanguage($code); |
139 | - return $this->cache[$code]['fallback']; |
|
139 | + return $this->cache[ $code ][ 'fallback' ]; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | static $languages_seen = array(); // recursion guard |
149 | 149 | |
150 | 150 | // abort if we've already loaded it |
151 | - if (isset($this->cache[$code])) { |
|
151 | + if (isset($this->cache[ $code ])) { |
|
152 | 152 | return; |
153 | 153 | } |
154 | 154 | |
155 | 155 | // generate filename |
156 | - $filename = $this->dir . '/Language/messages/' . $code . '.php'; |
|
156 | + $filename = $this->dir.'/Language/messages/'.$code.'.php'; |
|
157 | 157 | |
158 | 158 | // default fallback : may be overwritten by the ensuing include |
159 | 159 | $fallback = ($code != 'en') ? 'en' : false; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | // load primary localisation |
162 | 162 | if (!file_exists($filename)) { |
163 | 163 | // skip the include: will rely solely on fallback |
164 | - $filename = $this->dir . '/Language/messages/en.php'; |
|
164 | + $filename = $this->dir.'/Language/messages/en.php'; |
|
165 | 165 | $cache = array(); |
166 | 166 | } else { |
167 | 167 | include $filename; |
@@ -172,36 +172,36 @@ discard block |
||
172 | 172 | if (!empty($fallback)) { |
173 | 173 | |
174 | 174 | // infinite recursion guard |
175 | - if (isset($languages_seen[$code])) { |
|
175 | + if (isset($languages_seen[ $code ])) { |
|
176 | 176 | trigger_error( |
177 | - 'Circular fallback reference in language ' . |
|
177 | + 'Circular fallback reference in language '. |
|
178 | 178 | $code, |
179 | 179 | E_USER_ERROR |
180 | 180 | ); |
181 | 181 | $fallback = 'en'; |
182 | 182 | } |
183 | - $language_seen[$code] = true; |
|
183 | + $language_seen[ $code ] = true; |
|
184 | 184 | |
185 | 185 | // load the fallback recursively |
186 | 186 | $this->loadLanguage($fallback); |
187 | - $fallback_cache = $this->cache[$fallback]; |
|
187 | + $fallback_cache = $this->cache[ $fallback ]; |
|
188 | 188 | |
189 | 189 | // merge fallback with current language |
190 | 190 | foreach ($this->keys as $key) { |
191 | - if (isset($cache[$key]) && isset($fallback_cache[$key])) { |
|
192 | - if (isset($this->mergeable_keys_map[$key])) { |
|
193 | - $cache[$key] = $cache[$key] + $fallback_cache[$key]; |
|
194 | - } elseif (isset($this->mergeable_keys_list[$key])) { |
|
195 | - $cache[$key] = array_merge($fallback_cache[$key], $cache[$key]); |
|
191 | + if (isset($cache[ $key ]) && isset($fallback_cache[ $key ])) { |
|
192 | + if (isset($this->mergeable_keys_map[ $key ])) { |
|
193 | + $cache[ $key ] = $cache[ $key ] + $fallback_cache[ $key ]; |
|
194 | + } elseif (isset($this->mergeable_keys_list[ $key ])) { |
|
195 | + $cache[ $key ] = array_merge($fallback_cache[ $key ], $cache[ $key ]); |
|
196 | 196 | } |
197 | 197 | } else { |
198 | - $cache[$key] = $fallback_cache[$key]; |
|
198 | + $cache[ $key ] = $fallback_cache[ $key ]; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | // save to cache for later retrieval |
204 | - $this->cache[$code] = $cache; |
|
204 | + $this->cache[ $code ] = $cache; |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | // Note that ["<>] are an addition to the RFC's recommended |
32 | 32 | // characters, because they represent external delimeters. |
33 | 33 | $r_URI = '!'. |
34 | - '(([a-zA-Z0-9\.\+\-]+):)?'. // 2. Scheme |
|
35 | - '(//([^/?#"<>]*))?'. // 4. Authority |
|
36 | - '([^?#"<>]*)'. // 5. Path |
|
37 | - '(\?([^#"<>]*))?'. // 7. Query |
|
38 | - '(#([^"<>]*))?'. // 8. Fragment |
|
34 | + '(([a-zA-Z0-9\.\+\-]+):)?'.// 2. Scheme |
|
35 | + '(//([^/?#"<>]*))?'.// 4. Authority |
|
36 | + '([^?#"<>]*)'.// 5. Path |
|
37 | + '(\?([^#"<>]*))?'.// 7. Query |
|
38 | + '(#([^"<>]*))?'.// 8. Fragment |
|
39 | 39 | '!'; |
40 | 40 | |
41 | 41 | $matches = array(); |
@@ -44,20 +44,20 @@ discard block |
||
44 | 44 | if (!$result) return false; // *really* invalid URI |
45 | 45 | |
46 | 46 | // seperate out parts |
47 | - $scheme = !empty($matches[1]) ? $matches[2] : null; |
|
48 | - $authority = !empty($matches[3]) ? $matches[4] : null; |
|
49 | - $path = $matches[5]; // always present, can be empty |
|
50 | - $query = !empty($matches[6]) ? $matches[7] : null; |
|
51 | - $fragment = !empty($matches[8]) ? $matches[9] : null; |
|
47 | + $scheme = !empty($matches[ 1 ]) ? $matches[ 2 ] : null; |
|
48 | + $authority = !empty($matches[ 3 ]) ? $matches[ 4 ] : null; |
|
49 | + $path = $matches[ 5 ]; // always present, can be empty |
|
50 | + $query = !empty($matches[ 6 ]) ? $matches[ 7 ] : null; |
|
51 | + $fragment = !empty($matches[ 8 ]) ? $matches[ 9 ] : null; |
|
52 | 52 | |
53 | 53 | // further parse authority |
54 | 54 | if ($authority !== null) { |
55 | 55 | $r_authority = "/^((.+?)@)?(\[[^\]]+\]|[^:]*)(:(\d*))?/"; |
56 | 56 | $matches = array(); |
57 | 57 | preg_match($r_authority, $authority, $matches); |
58 | - $userinfo = !empty($matches[1]) ? $matches[2] : null; |
|
59 | - $host = !empty($matches[3]) ? $matches[3] : ''; |
|
60 | - $port = !empty($matches[4]) ? (int) $matches[5] : null; |
|
58 | + $userinfo = !empty($matches[ 1 ]) ? $matches[ 2 ] : null; |
|
59 | + $host = !empty($matches[ 3 ]) ? $matches[ 3 ] : ''; |
|
60 | + $port = !empty($matches[ 4 ]) ? (int) $matches[ 5 ] : null; |
|
61 | 61 | } else { |
62 | 62 | $port = $host = $userinfo = null; |
63 | 63 | } |
@@ -41,7 +41,10 @@ |
||
41 | 41 | $matches = array(); |
42 | 42 | $result = preg_match($r_URI, $uri, $matches); |
43 | 43 | |
44 | - if (!$result) return false; // *really* invalid URI |
|
44 | + if (!$result) { |
|
45 | + return false; |
|
46 | + } |
|
47 | + // *really* invalid URI |
|
45 | 48 | |
46 | 49 | // seperate out parts |
47 | 50 | $scheme = !empty($matches[1]) ? $matches[2] : null; |
@@ -139,7 +139,7 @@ |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | $mState = 0; // cached expected number of octets after the current octet |
142 | - // until the beginning of the next UTF8 character sequence |
|
142 | + // until the beginning of the next UTF8 character sequence |
|
143 | 143 | $mUcs4 = 0; // cached Unicode character |
144 | 144 | $mBytes = 1; // cached expected number of octets in the current sequence |
145 | 145 |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | break; |
72 | 72 | } |
73 | 73 | // wibble the boundary |
74 | - if (0x80 != (0xC0 & ord($text[$i + $max_chunk_size]))) { |
|
74 | + if (0x80 != (0xC0 & ord($text[ $i + $max_chunk_size ]))) { |
|
75 | 75 | $chunk_size = $max_chunk_size; |
76 | - } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 1]))) { |
|
76 | + } elseif (0x80 != (0xC0 & ord($text[ $i + $max_chunk_size - 1 ]))) { |
|
77 | 77 | $chunk_size = $max_chunk_size - 1; |
78 | - } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 2]))) { |
|
78 | + } elseif (0x80 != (0xC0 & ord($text[ $i + $max_chunk_size - 2 ]))) { |
|
79 | 79 | $chunk_size = $max_chunk_size - 2; |
80 | - } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 3]))) { |
|
80 | + } elseif (0x80 != (0xC0 & ord($text[ $i + $max_chunk_size - 3 ]))) { |
|
81 | 81 | $chunk_size = $max_chunk_size - 3; |
82 | 82 | } else { |
83 | 83 | return false; // rather confusing UTF-8... |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $len = strlen($str); |
156 | 156 | for ($i = 0; $i < $len; $i++) { |
157 | 157 | $in = ord($str{$i}); |
158 | - $char .= $str[$i]; // append byte to char |
|
158 | + $char .= $str[ $i ]; // append byte to char |
|
159 | 159 | if (0 == $mState) { |
160 | 160 | // When mState is zero we expect either a US-ASCII character |
161 | 161 | // or a multi-octet sequence. |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $mState = 0; |
274 | 274 | $mUcs4 = 0; |
275 | 275 | $mBytes = 1; |
276 | - $char =''; |
|
276 | + $char = ''; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | public static function unichr($code) |
310 | 310 | { |
311 | 311 | if ($code > 1114111 or $code < 0 or |
312 | - ($code >= 55296 and $code <= 57343) ) { |
|
312 | + ($code >= 55296 and $code <= 57343)) { |
|
313 | 313 | // bits are set outside the "valid" range as defined |
314 | 314 | // by UNICODE 4.1.0 |
315 | 315 | return ''; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $z = (($code >> 12) & 15) | 224; |
331 | 331 | } else { |
332 | 332 | $z = (($code >> 12) & 63) | 128; |
333 | - $w = (($code >> 18) & 7) | 240; |
|
333 | + $w = (($code >> 18) & 7) | 240; |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str); |
385 | 385 | if ($str === false) { |
386 | 386 | // $encoding is not a valid encoding |
387 | - trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR); |
|
387 | + trigger_error('Invalid encoding '.$encoding, E_USER_ERROR); |
|
388 | 388 | return ''; |
389 | 389 | } |
390 | 390 | // If the string is bjorked by Shift_JIS or a similar encoding |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | trigger_error('Encoding not supported, please install iconv', E_USER_ERROR); |
402 | 402 | } else { |
403 | 403 | trigger_error( |
404 | - 'You have a buggy version of iconv, see https://bugs.php.net/bug.php?id=48147 ' . |
|
404 | + 'You have a buggy version of iconv, see https://bugs.php.net/bug.php?id=48147 '. |
|
405 | 405 | 'and http://sourceware.org/bugzilla/show_bug.cgi?id=13541', |
406 | 406 | E_USER_ERROR |
407 | 407 | ); |
@@ -436,13 +436,13 @@ discard block |
||
436 | 436 | if (!$escape && !empty($ascii_fix)) { |
437 | 437 | $clear_fix = array(); |
438 | 438 | foreach ($ascii_fix as $utf8 => $native) { |
439 | - $clear_fix[$utf8] = ''; |
|
439 | + $clear_fix[ $utf8 ] = ''; |
|
440 | 440 | } |
441 | 441 | $str = strtr($str, $clear_fix); |
442 | 442 | } |
443 | 443 | $str = strtr($str, array_flip($ascii_fix)); |
444 | 444 | // Normal stuff |
445 | - $str = self::iconv('utf-8', $encoding . '//IGNORE', $str); |
|
445 | + $str = self::iconv('utf-8', $encoding.'//IGNORE', $str); |
|
446 | 446 | return $str; |
447 | 447 | } elseif ($encoding === 'iso-8859-1') { |
448 | 448 | $str = utf8_decode($str); |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | $working = 0; |
479 | 479 | $len = strlen($str); |
480 | 480 | for ($i = 0; $i < $len; $i++) { |
481 | - $bytevalue = ord($str[$i]); |
|
481 | + $bytevalue = ord($str[ $i ]); |
|
482 | 482 | if ($bytevalue <= 0x7F) { //0xxx xxxx |
483 | 483 | $result .= chr($bytevalue); |
484 | 484 | $bytesleft = 0; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $working += ($bytevalue & 0x3F); |
488 | 488 | $bytesleft--; |
489 | 489 | if ($bytesleft <= 0) { |
490 | - $result .= "&#" . $working . ";"; |
|
490 | + $result .= "&#".$working.";"; |
|
491 | 491 | } |
492 | 492 | } elseif ($bytevalue <= 0xDF) { //110x xxxx |
493 | 493 | $working = $bytevalue & 0x1F; |
@@ -533,14 +533,14 @@ discard block |
||
533 | 533 | static $code = null; |
534 | 534 | if ($code === null) { |
535 | 535 | // better not use iconv, otherwise infinite loop! |
536 | - $r = self::unsafeIconv('utf-8', 'ascii//IGNORE', "\xCE\xB1" . str_repeat('a', 9000)); |
|
536 | + $r = self::unsafeIconv('utf-8', 'ascii//IGNORE', "\xCE\xB1".str_repeat('a', 9000)); |
|
537 | 537 | if ($r === false) { |
538 | 538 | $code = self::ICONV_UNUSABLE; |
539 | 539 | } elseif (($c = strlen($r)) < 9000) { |
540 | 540 | $code = self::ICONV_TRUNCATES; |
541 | 541 | } elseif ($c > 9000) { |
542 | 542 | trigger_error( |
543 | - 'Your copy of iconv is extremely buggy. Please notify HTML Purifier maintainers: ' . |
|
543 | + 'Your copy of iconv is extremely buggy. Please notify HTML Purifier maintainers: '. |
|
544 | 544 | 'include your iconv version as per phpversion()', |
545 | 545 | E_USER_ERROR |
546 | 546 | ); |
@@ -571,8 +571,8 @@ discard block |
||
571 | 571 | // If ICONV_UNUSABLE, this call is irrelevant |
572 | 572 | static $encodings = array(); |
573 | 573 | if (!$bypass) { |
574 | - if (isset($encodings[$encoding])) { |
|
575 | - return $encodings[$encoding]; |
|
574 | + if (isset($encodings[ $encoding ])) { |
|
575 | + return $encodings[ $encoding ]; |
|
576 | 576 | } |
577 | 577 | $lenc = strtolower($encoding); |
578 | 578 | switch ($lenc) { |
@@ -600,10 +600,10 @@ discard block |
||
600 | 600 | // Reverse engineer: what's the UTF-8 equiv of this byte |
601 | 601 | // sequence? This assumes that there's no variable width |
602 | 602 | // encoding that doesn't support ASCII. |
603 | - $ret[self::unsafeIconv($encoding, 'UTF-8//IGNORE', $c)] = $c; |
|
603 | + $ret[ self::unsafeIconv($encoding, 'UTF-8//IGNORE', $c) ] = $c; |
|
604 | 604 | } |
605 | 605 | } |
606 | - $encodings[$encoding] = $ret; |
|
606 | + $encodings[ $encoding ] = $ret; |
|
607 | 607 | return $ret; |
608 | 608 | } |
609 | 609 | } |
@@ -328,7 +328,7 @@ |
||
328 | 328 | * Determines if a particular token requires an earlier inline token |
329 | 329 | * to get a paragraph. This should be used with _forwardUntilEndToken |
330 | 330 | * @param HTMLPurifier_Token $current |
331 | - * @return bool |
|
331 | + * @return boolean|null |
|
332 | 332 | */ |
333 | 333 | private function _checkNeedsP($current) |
334 | 334 | { |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | // important, otherwise attacker could include arbitrary file |
48 | 48 | $allowed_schemes = $config->get('URI.AllowedSchemes'); |
49 | 49 | if (!$config->get('URI.OverrideAllowedSchemes') && |
50 | - !isset($allowed_schemes[$scheme]) |
|
50 | + !isset($allowed_schemes[ $scheme ]) |
|
51 | 51 | ) { |
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | - if (isset($this->schemes[$scheme])) { |
|
56 | - return $this->schemes[$scheme]; |
|
55 | + if (isset($this->schemes[ $scheme ])) { |
|
56 | + return $this->schemes[ $scheme ]; |
|
57 | 57 | } |
58 | - if (!isset($allowed_schemes[$scheme])) { |
|
58 | + if (!isset($allowed_schemes[ $scheme ])) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - $class = 'HTMLPurifier_URIScheme_' . $scheme; |
|
62 | + $class = 'HTMLPurifier_URIScheme_'.$scheme; |
|
63 | 63 | if (!class_exists($class)) { |
64 | 64 | return; |
65 | 65 | } |
66 | - $this->schemes[$scheme] = new $class(); |
|
67 | - return $this->schemes[$scheme]; |
|
66 | + $this->schemes[ $scheme ] = new $class(); |
|
67 | + return $this->schemes[ $scheme ]; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function register($scheme, $scheme_obj) |
76 | 76 | { |
77 | - $this->schemes[$scheme] = $scheme_obj; |
|
77 | + $this->schemes[ $scheme ] = $scheme_obj; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 |