1 | <?php |
||
16 | class Sanitizer { |
||
17 | |||
18 | const WHITELIST = 'WHITELIST'; |
||
19 | const MIN_LENGTH = 'MIN_LENGTH'; |
||
20 | |||
21 | /** |
||
22 | * Any change to the content of its data files should be reflected in a |
||
23 | * version change (the version number does not necessarily correlate with |
||
24 | * the library version) |
||
25 | */ |
||
26 | const VERSION = '0.2'; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $string = ''; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | private $whiteList = array(); |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | private $minLength = 3; |
||
42 | |||
43 | /** |
||
44 | * @since 0.1 |
||
45 | * |
||
46 | * @param string $string |
||
47 | */ |
||
48 | 13 | public function __construct( $string = '' ) { |
|
49 | 13 | $this->setText( $string ); |
|
50 | 13 | } |
|
51 | |||
52 | /** |
||
53 | * @since 1.0 |
||
54 | * |
||
55 | * @param string $name |
||
56 | * @param mixed $value |
||
57 | */ |
||
58 | 1 | public function setOption( $name, $value ) { |
|
59 | |||
60 | 1 | if ( $name === self::WHITELIST && is_array( $value ) && $value !== array() ) { |
|
61 | 1 | $this->whiteList = array_fill_keys( $value, true ); |
|
62 | 1 | } |
|
63 | |||
64 | 1 | if ( $name === self::MIN_LENGTH ) { |
|
65 | 1 | $this->minLength = (int)$value; |
|
|
|||
66 | 1 | } |
|
67 | 1 | } |
|
68 | |||
69 | /** |
||
70 | * @since 0.1 |
||
71 | * |
||
72 | * @param string $string |
||
73 | */ |
||
74 | 13 | public function setText( $string ) { |
|
77 | |||
78 | /** |
||
79 | * @since 0.1 |
||
80 | * |
||
81 | * @param integer $flag |
||
82 | */ |
||
83 | 1 | public function applyTransliteration( $flag = Transliterator::DIACRITICS ) { |
|
86 | |||
87 | /** |
||
88 | * @see Localizer::convertDoubleWidth |
||
89 | * |
||
90 | * @since 0.1 |
||
91 | * |
||
92 | * @param integer $flag |
||
93 | */ |
||
94 | public function convertDoubleWidth() { |
||
97 | |||
98 | /** |
||
99 | * @since 0.1 |
||
100 | * |
||
101 | * @param Tokenizer $tokenizer |
||
102 | * @param StopwordAnalyzer $stopwordAnalyzer |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 7 | public function sanitizeWith( Tokenizer $tokenizer, StopwordAnalyzer $stopwordAnalyzer, Synonymizer $synonymizer ) { |
|
141 | |||
142 | /** |
||
143 | * @since 0.1 |
||
144 | */ |
||
145 | 5 | public function toLowercase() { |
|
148 | |||
149 | /** |
||
150 | * @since 0.1 |
||
151 | * |
||
152 | * @param integer $length |
||
153 | */ |
||
154 | 3 | public function reduceLengthTo( $length ) { |
|
157 | |||
158 | /** |
||
159 | * @see http://www.phpwact.org/php/i18n/utf-8#str_replace |
||
160 | * @since 0.1 |
||
161 | * |
||
162 | * @param string $search |
||
163 | * @param string $replace |
||
164 | */ |
||
165 | 1 | public function replace( $search, $replace ) { |
|
168 | |||
169 | /** |
||
170 | * @since 0.1 |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | 6 | public function __toString() { |
|
177 | |||
178 | } |
||
179 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..