1 | <?php |
||
30 | class Pinyin |
||
31 | { |
||
32 | const NONE = 'none'; |
||
33 | |||
34 | const ASCII = 'ascii'; |
||
35 | |||
36 | const UNICODE = 'unicode'; |
||
37 | |||
38 | /** |
||
39 | * Dict loader. |
||
40 | * |
||
41 | * @var \Overtrue\Pinyin\DictLoaderInterface |
||
42 | */ |
||
43 | protected $loader; |
||
44 | |||
45 | /** |
||
46 | * Punctuations map. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $punctuations = array( |
||
51 | ',' => ',', |
||
52 | '。' => '.', |
||
53 | '!' => '!', |
||
54 | '?' => '?', |
||
55 | ':' => ':', |
||
56 | '“' => '"', |
||
57 | '”' => '"', |
||
58 | '‘' => "'", |
||
59 | '’' => "'", |
||
60 | ); |
||
61 | |||
62 | 21 | /** |
|
63 | * Constructor. |
||
64 | 21 | * |
|
65 | 21 | * @param string $loaderName |
|
66 | */ |
||
67 | public function __construct($loaderName = null) |
||
71 | |||
72 | /** |
||
73 | * Convert string to pinyin. |
||
74 | * |
||
75 | 10 | * @param string $string |
|
76 | * @param string $option |
||
77 | 10 | * |
|
78 | * @return array |
||
79 | 10 | */ |
|
80 | public function convert($string, $option = self::NONE) |
||
86 | |||
87 | /** |
||
88 | * Convert string (person name) to pinyin. |
||
89 | * |
||
90 | 2 | * @param string $stringName |
|
91 | * @param string $option |
||
92 | 2 | * |
|
93 | * @return array |
||
94 | 2 | */ |
|
95 | public function name($stringName, $option = self::NONE) |
||
101 | |||
102 | /** |
||
103 | * Return a pinyin permalink from string. |
||
104 | * |
||
105 | 2 | * @param string $string |
|
106 | * @param string $delimiter |
||
107 | 2 | * |
|
108 | 2 | * @return string |
|
109 | */ |
||
110 | public function permalink($string, $delimiter = '-') |
||
118 | |||
119 | /** |
||
120 | * Return first letters. |
||
121 | * |
||
122 | 2 | * @param string $string |
|
123 | * @param string $delimiter |
||
124 | * |
||
125 | 2 | * @return string |
|
126 | 2 | */ |
|
127 | public function abbr($string, $delimiter = '') |
||
133 | |||
134 | /** |
||
135 | * Chinese phrase to pinyin. |
||
136 | * |
||
137 | * @param string $string |
||
138 | 2 | * @param string $delimiter |
|
139 | * @param string $option |
||
140 | 2 | * |
|
141 | * @return string |
||
142 | */ |
||
143 | public function phrase($string, $delimiter = ' ', $option = self::NONE) |
||
147 | |||
148 | /** |
||
149 | * Chinese to pinyin sentense. |
||
150 | * |
||
151 | 9 | * @param string $sentence |
|
152 | * @param bool $withTone |
||
153 | 9 | * |
|
154 | 9 | * @return string |
|
155 | 9 | */ |
|
156 | public function sentence($sentence, $withTone = false) |
||
169 | |||
170 | /** |
||
171 | * Loader setter. |
||
172 | 1 | * |
|
173 | * @param \Overtrue\Pinyin\DictLoaderInterface $loader |
||
174 | 1 | * |
|
175 | * @return $this |
||
176 | 1 | */ |
|
177 | public function setLoader(DictLoaderInterface $loader) |
||
183 | |||
184 | 21 | /** |
|
185 | * Return dict loader,. |
||
186 | 21 | * |
|
187 | 20 | * @return \Overtrue\Pinyin\DictLoaderInterface |
|
188 | */ |
||
189 | 20 | public function getLoader() |
|
200 | |||
201 | /** |
||
202 | * Preprocess. |
||
203 | 21 | * |
|
204 | * @param string $string |
||
205 | * |
||
206 | 8 | * @return string |
|
207 | 21 | */ |
|
208 | protected function prepare($string) |
||
216 | |||
217 | /** |
||
218 | * Convert Chinese to pinyin. |
||
219 | * |
||
220 | 21 | * @param string $string |
|
221 | * @param bool $isName |
||
222 | 21 | * |
|
223 | * @return string |
||
224 | 21 | */ |
|
225 | protected function romanize($string, $isName = false) |
||
241 | |||
242 | /** |
||
243 | * Convert Chinese Surname to pinyin. |
||
244 | * |
||
245 | * @param string $string |
||
246 | * @param \Overtrue\Pinyin\DictLoaderInterface $dictLoader |
||
247 | 2 | * |
|
248 | 2 | * @return string |
|
249 | 2 | */ |
|
250 | 2 | protected function convertSurname($string, $dictLoader) |
|
264 | |||
265 | /** |
||
266 | * Split pinyin string to words. |
||
267 | 12 | * |
|
268 | * @param string $pinyin |
||
269 | 12 | * @param string $option |
|
270 | * |
||
271 | 12 | * @return array |
|
272 | 10 | */ |
|
273 | 10 | public function splitWords($pinyin, $option) |
|
285 | |||
286 | /** |
||
287 | * Format. |
||
288 | 17 | * |
|
289 | * @param string $pinyin |
||
290 | * @param bool $tone |
||
291 | 17 | * |
|
292 | 17 | * @return string |
|
293 | 17 | */ |
|
294 | 17 | protected function format($pinyin, $tone = false) |
|
312 | } |
||
313 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: