1 | <?php |
||
27 | class Pinyin |
||
28 | { |
||
29 | const NONE = 'none'; |
||
30 | const ASCII = 'ascii'; |
||
31 | const UNICODE = 'unicode'; |
||
32 | |||
33 | /** |
||
34 | * Dict loader. |
||
35 | * |
||
36 | * @var \Overtrue\Pinyin\DictLoaderInterface |
||
37 | */ |
||
38 | protected $loader; |
||
39 | |||
40 | /** |
||
41 | * Punctuations map. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $punctuations = array( |
||
46 | ',' => ',', |
||
47 | '。' => '.', |
||
48 | '!' => '!', |
||
49 | '?' => '?', |
||
50 | ':' => ':', |
||
51 | '“' => '"', |
||
52 | '”' => '"', |
||
53 | '‘' => "'", |
||
54 | '’' => "'", |
||
55 | ); |
||
56 | |||
57 | /** |
||
58 | * Constructor. |
||
59 | * |
||
60 | * @param string $loaderName |
||
61 | */ |
||
62 | 19 | public function __construct($loaderName = null) |
|
66 | |||
67 | /** |
||
68 | * Convert string to pinyin. |
||
69 | * |
||
70 | * @param string $string |
||
71 | * @param string $option |
||
72 | * |
||
73 | * @return array |
||
74 | */ |
||
75 | 8 | public function convert($string, $option = self::NONE) |
|
81 | |||
82 | /** |
||
83 | * Convert string (person name) to pinyin. |
||
84 | * |
||
85 | * @param string $stringName |
||
86 | * @param string $option |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | 2 | public function name($stringName, $option = self::NONE) |
|
96 | |||
97 | /** |
||
98 | * Return a pinyin permalink from string. |
||
99 | * |
||
100 | * @param string $string |
||
101 | * @param string $delimiter |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | 2 | public function permalink($string, $delimiter = '-') |
|
113 | |||
114 | /** |
||
115 | * Return first letters. |
||
116 | * |
||
117 | * @param string $string |
||
118 | * @param string $delimiter |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | 2 | public function abbr($string, $delimiter = '') |
|
128 | |||
129 | /** |
||
130 | * Chinese phrase to pinyin. |
||
131 | * |
||
132 | * @param string $string |
||
133 | * @param string $delimiter |
||
134 | * @param string $option |
||
135 | * |
||
136 | * @return string |
||
137 | 9 | */ |
|
138 | public function phrase($string, $delimiter = ' ', $option = self::NONE) { |
||
143 | 9 | ||
144 | /** |
||
145 | 9 | * Chinese to pinyin sentense. |
|
146 | 9 | * |
|
147 | * @param string $sentence |
||
148 | 9 | * @param bool $withTone |
|
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | public function sentence($sentence, $withTone = false) |
||
165 | |||
166 | /** |
||
167 | * Loader setter. |
||
168 | * |
||
169 | * @param \Overtrue\Pinyin\DictLoaderInterface $loader |
||
170 | 19 | * |
|
171 | * @return $this |
||
172 | 19 | */ |
|
173 | 18 | public function setLoader(DictLoaderInterface $loader) |
|
179 | 19 | ||
180 | /** |
||
181 | * Return dict loader,. |
||
182 | * |
||
183 | * @return \Overtrue\Pinyin\DictLoaderInterface |
||
184 | */ |
||
185 | public function getLoader() |
||
196 | |||
197 | /** |
||
198 | * Preprocess. |
||
199 | * |
||
200 | * @param string $string |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | protected function prepare($string) |
||
212 | 19 | ||
213 | 2 | /** |
|
214 | 2 | * Convert Chinese to pinyin. |
|
215 | * |
||
216 | * @param string $string |
||
217 | 19 | * @param bool $isName |
|
218 | 19 | * |
|
219 | * @return string |
||
220 | 19 | */ |
|
221 | protected function romanize($string, $isName = false) |
||
237 | 2 | ||
238 | /** |
||
239 | 2 | * Convert Chinese Surname to pinyin. |
|
240 | 2 | * |
|
241 | * @param string $string |
||
242 | 2 | * @param \Overtrue\Pinyin\DictLoaderInterface $dictLoader |
|
243 | * |
||
244 | * @return string |
||
245 | */ |
||
246 | protected function convertSurname($string, $dictLoader) |
||
259 | 8 | ||
260 | 8 | /** |
|
261 | 8 | * Split pinyin string to words. |
|
262 | * |
||
263 | 10 | * @param string $pinyin |
|
264 | * @param string $option |
||
265 | * |
||
266 | * @return array |
||
267 | */ |
||
268 | public function splitWords($pinyin, $option) |
||
280 | 15 | ||
281 | 15 | /** |
|
282 | 15 | * Format. |
|
283 | * |
||
284 | 15 | * @param string $pinyin |
|
285 | 15 | * @param bool $tone |
|
286 | 14 | * |
|
287 | 14 | * @return string |
|
288 | 15 | */ |
|
289 | protected function format($pinyin, $tone = false) |
||
307 | } |
||
308 |
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..