@@ -24,7 +24,7 @@ |
||
24 | 24 | * @param string $number |
25 | 25 | * @param HTMLPurifier_Config $config |
26 | 26 | * @param HTMLPurifier_Context $context |
27 | - * @return string|bool |
|
27 | + * @return false|string |
|
28 | 28 | * @warning Some contexts do not pass $config, $context. These |
29 | 29 | * variables should not be used without checking HTMLPurifier_Length |
30 | 30 | */ |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | if (ctype_digit($number)) { |
54 | 54 | $number = ltrim($number, '0'); |
55 | - return $number ? $sign . $number : '0'; |
|
55 | + return $number ? $sign.$number : '0'; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Period is the only non-numeric character allowed |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | $right = rtrim($right, '0'); |
74 | 74 | |
75 | 75 | if ($right === '') { |
76 | - return $left ? $sign . $left : '0'; |
|
76 | + return $left ? $sign.$left : '0'; |
|
77 | 77 | } elseif (!ctype_digit($right)) { |
78 | 78 | return false; |
79 | 79 | } |
80 | - return $sign . $left . '.' . $right; |
|
80 | + return $sign.$left.'.'.$right; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * @param string $string |
29 | 29 | * @param HTMLPurifier_Config $config |
30 | 30 | * @param HTMLPurifier_Context $context |
31 | - * @return bool|string |
|
31 | + * @return boolean |
|
32 | 32 | */ |
33 | 33 | public function validate($string, $config, $context) |
34 | 34 | { |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @param string $string |
25 | 25 | * @param HTMLPurifier_Config $config |
26 | 26 | * @param HTMLPurifier_Context $context |
27 | - * @return bool|string |
|
27 | + * @return string|false |
|
28 | 28 | */ |
29 | 29 | public function validate($string, $config, $context) |
30 | 30 | { |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @param string $string |
11 | 11 | * @param HTMLPurifier_Config $config |
12 | 12 | * @param HTMLPurifier_Context $context |
13 | - * @return bool|string |
|
13 | + * @return false|string |
|
14 | 14 | */ |
15 | 15 | public function validate($string, $config, $context) |
16 | 16 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $string |
35 | 35 | * @param HTMLPurifier_Config $config |
36 | 36 | * @param HTMLPurifier_Context $context |
37 | - * @return array |
|
37 | + * @return string[] |
|
38 | 38 | */ |
39 | 39 | protected function split($string, $config, $context) |
40 | 40 | { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * Template method for removing certain tokens based on arbitrary criteria. |
57 | 57 | * @note If we wanted to be really functional, we'd do an array_filter |
58 | 58 | * with a callback. But... we're not. |
59 | - * @param array $tokens |
|
59 | + * @param string[] $tokens |
|
60 | 60 | * @param HTMLPurifier_Config $config |
61 | 61 | * @param HTMLPurifier_Context $context |
62 | 62 | * @return array |
@@ -45,8 +45,8 @@ |
||
45 | 45 | // escaping because I don't know how to do that with regexps |
46 | 46 | // and plus it would complicate optimization efforts (you never |
47 | 47 | // see that anyway). |
48 | - $pattern = '/(?:(?<=\s)|\A)' . // look behind for space or string start |
|
49 | - '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)' . |
|
48 | + $pattern = '/(?:(?<=\s)|\A)'.// look behind for space or string start |
|
49 | + '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)'. |
|
50 | 50 | '(?:(?=\s)|\z)/'; // look ahead for space or string end |
51 | 51 | preg_match_all($pattern, $string, $matches); |
52 | 52 | return $matches[1]; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | * @param string $aIP |
14 | 14 | * @param HTMLPurifier_Config $config |
15 | 15 | * @param HTMLPurifier_Context $context |
16 | - * @return bool|string |
|
16 | + * @return false|string |
|
17 | 17 | */ |
18 | 18 | public function validate($aIP, $config, $context) |
19 | 19 | { |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | $original = $aIP; |
25 | 25 | |
26 | 26 | $hex = '[0-9a-fA-F]'; |
27 | - $blk = '(?:' . $hex . '{1,4})'; |
|
27 | + $blk = '(?:'.$hex.'{1,4})'; |
|
28 | 28 | $pre = '(?:/(?:12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9]))'; // /0 - /128 |
29 | 29 | |
30 | 30 | // prefix check |
31 | 31 | if (strpos($aIP, '/') !== false) { |
32 | - if (preg_match('#' . $pre . '$#s', $aIP, $find)) { |
|
32 | + if (preg_match('#'.$pre.'$#s', $aIP, $find)) { |
|
33 | 33 | $aIP = substr($aIP, 0, 0 - strlen($find[0])); |
34 | 34 | unset($find); |
35 | 35 | } else { |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | // IPv4-compatiblity check |
41 | - if (preg_match('#(?<=:' . ')' . $this->ip4 . '$#s', $aIP, $find)) { |
|
41 | + if (preg_match('#(?<=:'.')'.$this->ip4.'$#s', $aIP, $find)) { |
|
42 | 42 | $aIP = substr($aIP, 0, 0 - strlen($find[0])); |
43 | 43 | $ip = explode('.', $find[0]); |
44 | 44 | $ip = array_map('dechex', $ip); |
45 | - $aIP .= $ip[0] . $ip[1] . ':' . $ip[2] . $ip[3]; |
|
45 | + $aIP .= $ip[0].$ip[1].':'.$ip[2].$ip[3]; |
|
46 | 46 | unset($find, $ip); |
47 | 47 | } |
48 | 48 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | private $_pcre_regex; |
32 | 32 | |
33 | 33 | /** |
34 | - * @param $dtd_regex Allowed child pattern from the DTD |
|
34 | + * @param string $dtd_regex Allowed child pattern from the DTD |
|
35 | 35 | */ |
36 | 36 | public function __construct($dtd_regex) |
37 | 37 | { |
@@ -86,16 +86,16 @@ |
||
86 | 86 | if (!empty($node->is_whitespace)) { |
87 | 87 | continue; |
88 | 88 | } |
89 | - $list_of_children .= $node->name . ','; |
|
89 | + $list_of_children .= $node->name.','; |
|
90 | 90 | } |
91 | 91 | // add leading comma to deal with stray comma declarations |
92 | - $list_of_children = ',' . rtrim($list_of_children, ','); |
|
92 | + $list_of_children = ','.rtrim($list_of_children, ','); |
|
93 | 93 | $okay = |
94 | 94 | preg_match( |
95 | - '/^,?' . $this->_pcre_regex . '$/', |
|
95 | + '/^,?'.$this->_pcre_regex.'$/', |
|
96 | 96 | $list_of_children |
97 | 97 | ); |
98 | - return (bool)$okay; |
|
98 | + return (bool) $okay; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public $type = 'optional'; |
21 | 21 | |
22 | 22 | /** |
23 | - * @param array $children |
|
23 | + * @param HTMLPurifier_Node[] $children |
|
24 | 24 | * @param HTMLPurifier_Config $config |
25 | 25 | * @param HTMLPurifier_Context $context |
26 | 26 | * @return array |
@@ -763,7 +763,7 @@ |
||
763 | 763 | * @param bool $mq_fix Boolean whether or not to enable magic quotes fix |
764 | 764 | * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy |
765 | 765 | * |
766 | - * @return mixed |
|
766 | + * @return HTMLPurifier_Config |
|
767 | 767 | */ |
768 | 768 | public static function loadArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) |
769 | 769 | { |
@@ -782,8 +782,8 @@ |
||
782 | 782 | */ |
783 | 783 | public function mergeArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true) |
784 | 784 | { |
785 | - $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $this->def); |
|
786 | - $this->loadArray($ret); |
|
785 | + $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $this->def); |
|
786 | + $this->loadArray($ret); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | if (!isset($this->def->info[$key])) { |
182 | 182 | // can't add % due to SimpleTest bug |
183 | 183 | $this->triggerError( |
184 | - 'Cannot retrieve value of undefined directive ' . htmlspecialchars($key), |
|
184 | + 'Cannot retrieve value of undefined directive '.htmlspecialchars($key), |
|
185 | 185 | E_USER_WARNING |
186 | 186 | ); |
187 | 187 | return; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | if (isset($this->def->info[$key]->isAlias)) { |
190 | 190 | $d = $this->def->info[$key]; |
191 | 191 | $this->triggerError( |
192 | - 'Cannot get value from aliased directive, use real name ' . $d->key, |
|
192 | + 'Cannot get value from aliased directive, use real name '.$d->key, |
|
193 | 193 | E_USER_ERROR |
194 | 194 | ); |
195 | 195 | return; |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | list($ns) = explode('.', $key); |
199 | 199 | if ($ns !== $this->lock) { |
200 | 200 | $this->triggerError( |
201 | - 'Cannot get value of namespace ' . $ns . ' when lock for ' . |
|
202 | - $this->lock . |
|
203 | - ' is active, this probably indicates a Definition setup method ' . |
|
201 | + 'Cannot get value of namespace '.$ns.' when lock for '. |
|
202 | + $this->lock. |
|
203 | + ' is active, this probably indicates a Definition setup method '. |
|
204 | 204 | 'is accessing directives that are not within its namespace', |
205 | 205 | E_USER_ERROR |
206 | 206 | ); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $full = $this->getAll(); |
226 | 226 | if (!isset($full[$namespace])) { |
227 | 227 | $this->triggerError( |
228 | - 'Cannot retrieve undefined namespace ' . |
|
228 | + 'Cannot retrieve undefined namespace '. |
|
229 | 229 | htmlspecialchars($namespace), |
230 | 230 | E_USER_WARNING |
231 | 231 | ); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | } |
310 | 310 | if (!isset($this->def->info[$key])) { |
311 | 311 | $this->triggerError( |
312 | - 'Cannot set undefined directive ' . htmlspecialchars($key) . ' to value', |
|
312 | + 'Cannot set undefined directive '.htmlspecialchars($key).' to value', |
|
313 | 313 | E_USER_WARNING |
314 | 314 | ); |
315 | 315 | return; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | if ($this->aliasMode) { |
321 | 321 | $this->triggerError( |
322 | 322 | 'Double-aliases not allowed, please fix '. |
323 | - 'ConfigSchema bug with' . $key, |
|
323 | + 'ConfigSchema bug with'.$key, |
|
324 | 324 | E_USER_ERROR |
325 | 325 | ); |
326 | 326 | return; |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $value = $this->parser->parse($value, $type, $allow_null); |
348 | 348 | } catch (HTMLPurifier_VarParserException $e) { |
349 | 349 | $this->triggerError( |
350 | - 'Value for ' . $key . ' is of invalid type, should be ' . |
|
350 | + 'Value for '.$key.' is of invalid type, should be '. |
|
351 | 351 | HTMLPurifier_VarParser::getTypeName($type), |
352 | 352 | E_USER_WARNING |
353 | 353 | ); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | // check to see if the value is allowed |
362 | 362 | if (isset($def->allowed) && !isset($def->allowed[$value])) { |
363 | 363 | $this->triggerError( |
364 | - 'Value not supported, valid values are: ' . |
|
364 | + 'Value not supported, valid values are: '. |
|
365 | 365 | $this->_listify($def->allowed), |
366 | 366 | E_USER_WARNING |
367 | 367 | ); |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | // check preconditions |
525 | 525 | $def = null; |
526 | 526 | if ($optimized) { |
527 | - if (is_null($this->get($type . '.DefinitionID'))) { |
|
527 | + if (is_null($this->get($type.'.DefinitionID'))) { |
|
528 | 528 | // fatally error out if definition ID not set |
529 | 529 | throw new HTMLPurifier_Exception( |
530 | 530 | "Cannot retrieve raw version without specifying %$type.DefinitionID" |
@@ -535,17 +535,16 @@ discard block |
||
535 | 535 | $def = $this->definitions[$type]; |
536 | 536 | if ($def->setup && !$optimized) { |
537 | 537 | $extra = $this->chatty ? |
538 | - " (try moving this code block earlier in your initialization)" : |
|
539 | - ""; |
|
538 | + " (try moving this code block earlier in your initialization)" : ""; |
|
540 | 539 | throw new HTMLPurifier_Exception( |
541 | - "Cannot retrieve raw definition after it has already been setup" . |
|
540 | + "Cannot retrieve raw definition after it has already been setup". |
|
542 | 541 | $extra |
543 | 542 | ); |
544 | 543 | } |
545 | 544 | if ($def->optimized === null) { |
546 | 545 | $extra = $this->chatty ? " (try flushing your cache)" : ""; |
547 | 546 | throw new HTMLPurifier_Exception( |
548 | - "Optimization status of definition is unknown" . $extra |
|
547 | + "Optimization status of definition is unknown".$extra |
|
549 | 548 | ); |
550 | 549 | } |
551 | 550 | if ($def->optimized !== $optimized) { |
@@ -554,7 +553,7 @@ discard block |
||
554 | 553 | " (this backtrace is for the first inconsistent call, which was for a $msg raw definition)" |
555 | 554 | : ""; |
556 | 555 | throw new HTMLPurifier_Exception( |
557 | - "Inconsistent use of optimized and unoptimized raw definition retrievals" . $extra |
|
556 | + "Inconsistent use of optimized and unoptimized raw definition retrievals".$extra |
|
558 | 557 | ); |
559 | 558 | } |
560 | 559 | } |
@@ -586,16 +585,16 @@ discard block |
||
586 | 585 | } |
587 | 586 | // check invariants for creation |
588 | 587 | if (!$optimized) { |
589 | - if (!is_null($this->get($type . '.DefinitionID'))) { |
|
588 | + if (!is_null($this->get($type.'.DefinitionID'))) { |
|
590 | 589 | if ($this->chatty) { |
591 | 590 | $this->triggerError( |
592 | - 'Due to a documentation error in previous version of HTML Purifier, your ' . |
|
593 | - 'definitions are not being cached. If this is OK, you can remove the ' . |
|
594 | - '%$type.DefinitionRev and %$type.DefinitionID declaration. Otherwise, ' . |
|
595 | - 'modify your code to use maybeGetRawDefinition, and test if the returned ' . |
|
596 | - 'value is null before making any edits (if it is null, that means that a ' . |
|
597 | - 'cached version is available, and no raw operations are necessary). See ' . |
|
598 | - '<a href="http://htmlpurifier.org/docs/enduser-customize.html#optimized">' . |
|
591 | + 'Due to a documentation error in previous version of HTML Purifier, your '. |
|
592 | + 'definitions are not being cached. If this is OK, you can remove the '. |
|
593 | + '%$type.DefinitionRev and %$type.DefinitionID declaration. Otherwise, '. |
|
594 | + 'modify your code to use maybeGetRawDefinition, and test if the returned '. |
|
595 | + 'value is null before making any edits (if it is null, that means that a '. |
|
596 | + 'cached version is available, and no raw operations are necessary). See '. |
|
597 | + '<a href="http://htmlpurifier.org/docs/enduser-customize.html#optimized">'. |
|
599 | 598 | 'Customize</a> for more details', |
600 | 599 | E_USER_WARNING |
601 | 600 | ); |
@@ -689,7 +688,7 @@ discard block |
||
689 | 688 | $namespace = $key; |
690 | 689 | $namespace_values = $value; |
691 | 690 | foreach ($namespace_values as $directive => $value2) { |
692 | - $this->set($namespace .'.'. $directive, $value2); |
|
691 | + $this->set($namespace.'.'.$directive, $value2); |
|
693 | 692 | } |
694 | 693 | } |
695 | 694 | } |
@@ -898,7 +897,7 @@ discard block |
||
898 | 897 | break; |
899 | 898 | } |
900 | 899 | } |
901 | - trigger_error($msg . $extra, $no); |
|
900 | + trigger_error($msg.$extra, $no); |
|
902 | 901 | } |
903 | 902 | |
904 | 903 | /** |
@@ -133,7 +133,9 @@ |
||
133 | 133 | } |
134 | 134 | if (is_string($config)) { |
135 | 135 | $ret->loadIni($config); |
136 | - } elseif (is_array($config)) $ret->loadArray($config); |
|
136 | + } elseif (is_array($config)) { |
|
137 | + $ret->loadArray($config); |
|
138 | + } |
|
137 | 139 | return $ret; |
138 | 140 | } |
139 | 141 |
@@ -451,7 +451,7 @@ |
||
451 | 451 | * separate lists for processing. Format is element[attr1|attr2],element2... |
452 | 452 | * @warning Although it's largely drawn from TinyMCE's implementation, |
453 | 453 | * it is different, and you'll probably have to modify your lists |
454 | - * @param array $list String list to parse |
|
454 | + * @param string $list String list to parse |
|
455 | 455 | * @return array |
456 | 456 | * @todo Give this its own class, probably static interface |
457 | 457 | */ |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | if ($delete) { |
351 | 351 | if ($this->info[$tag]->attr[$attr]->required) { |
352 | 352 | trigger_error( |
353 | - "Required attribute '$attr' in element '$tag' " . |
|
353 | + "Required attribute '$attr' in element '$tag' ". |
|
354 | 354 | "was not allowed, which means '$tag' will not be allowed either", |
355 | 355 | E_USER_WARNING |
356 | 356 | ); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $attribute = htmlspecialchars($bits[1]); |
371 | 371 | if (!isset($this->info[$element])) { |
372 | 372 | trigger_error( |
373 | - "Cannot allow attribute '$attribute' if element " . |
|
373 | + "Cannot allow attribute '$attribute' if element ". |
|
374 | 374 | "'$element' is not allowed/supported $support" |
375 | 375 | ); |
376 | 376 | } else { |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } elseif (isset($forbidden_attributes["$tag.$attr"])) { // this segment might get removed eventually |
415 | 415 | // $tag.$attr are not user supplied, so no worries! |
416 | 416 | trigger_error( |
417 | - "Error with $tag.$attr: tag.attr syntax not supported for " . |
|
417 | + "Error with $tag.$attr: tag.attr syntax not supported for ". |
|
418 | 418 | "HTML.ForbiddenAttributes; use tag@attr instead", |
419 | 419 | E_USER_WARNING |
420 | 420 | ); |