Exceptions
5 days ago
apache.php
5 days ago
apcu.php
5 days ago
array.php
5 days ago
bzip2.php
5 days ago
calendar.php
5 days ago
classobj.php
5 days ago
com.php
5 days ago
cubrid.php
5 days ago
curl.php
5 days ago
datetime.php
5 days ago
dir.php
5 days ago
eio.php
5 days ago
errorfunc.php
5 days ago
exec.php
5 days ago
fileinfo.php
5 days ago
filesystem.php
5 days ago
filter.php
5 days ago
fpm.php
5 days ago
ftp.php
5 days ago
funchand.php
5 days ago
functionsList.php
5 days ago
gmp.php
5 days ago
gnupg.php
5 days ago
hash.php
5 days ago
ibase.php
5 days ago
ibmDb2.php
5 days ago
iconv.php
5 days ago
image.php
5 days ago
imap.php
5 days ago
info.php
5 days ago
ingres-ii.php
5 days ago
inotify.php
5 days ago
json.php
5 days ago
ldap.php
5 days ago
libxml.php
5 days ago
lzf.php
5 days ago
mailparse.php
5 days ago
mbstring.php
5 days ago
misc.php
5 days ago
msql.php
5 days ago
mysql.php
5 days ago
mysqli.php
5 days ago
mysqlndMs.php
5 days ago
mysqlndQc.php
5 days ago
network.php
5 days ago
oci8.php
5 days ago
opcache.php
5 days ago
openssl.php
5 days ago
outcontrol.php
5 days ago
password.php
5 days ago
pcntl.php
5 days ago
pcre.php
5 days ago
pdf.php
5 days ago
pgsql.php
5 days ago
posix.php
5 days ago
ps.php
5 days ago
pspell.php
5 days ago
readline.php
5 days ago
rpminfo.php
5 days ago
rrd.php
5 days ago
sem.php
5 days ago
session.php
5 days ago
shmop.php
5 days ago
simplexml.php
5 days ago
sockets.php
5 days ago
sodium.php
5 days ago
solr.php
5 days ago
spl.php
5 days ago
sqlsrv.php
5 days ago
ssdeep.php
5 days ago
ssh2.php
5 days ago
stream.php
5 days ago
strings.php
5 days ago
swoole.php
5 days ago
uodbc.php
5 days ago
uopz.php
5 days ago
url.php
5 days ago
var.php
5 days ago
xdiff.php
5 days ago
xml.php
5 days ago
xmlrpc.php
5 days ago
yaml.php
5 days ago
yaz.php
5 days ago
zip.php
5 days ago
zlib.php
5 days ago
pspell.php
421 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePressVendor\Safe; |
| 4 | |
| 5 | use ProfilePressVendor\Safe\Exceptions\PspellException; |
| 6 | /** |
| 7 | * |
| 8 | * |
| 9 | * @param int $dictionary_link |
| 10 | * @param string $word The added word. |
| 11 | * @throws PspellException |
| 12 | * |
| 13 | */ |
| 14 | function pspell_add_to_personal(int $dictionary_link, string $word): void |
| 15 | { |
| 16 | error_clear_last(); |
| 17 | $result = \pspell_add_to_personal($dictionary_link, $word); |
| 18 | if ($result === \false) { |
| 19 | throw PspellException::createFromPhpError(); |
| 20 | } |
| 21 | } |
| 22 | /** |
| 23 | * |
| 24 | * |
| 25 | * @param int $dictionary_link |
| 26 | * @param string $word The added word. |
| 27 | * @throws PspellException |
| 28 | * |
| 29 | */ |
| 30 | function pspell_add_to_session(int $dictionary_link, string $word): void |
| 31 | { |
| 32 | error_clear_last(); |
| 33 | $result = \pspell_add_to_session($dictionary_link, $word); |
| 34 | if ($result === \false) { |
| 35 | throw PspellException::createFromPhpError(); |
| 36 | } |
| 37 | } |
| 38 | /** |
| 39 | * |
| 40 | * |
| 41 | * @param int $dictionary_link |
| 42 | * @throws PspellException |
| 43 | * |
| 44 | */ |
| 45 | function pspell_clear_session(int $dictionary_link): void |
| 46 | { |
| 47 | error_clear_last(); |
| 48 | $result = \pspell_clear_session($dictionary_link); |
| 49 | if ($result === \false) { |
| 50 | throw PspellException::createFromPhpError(); |
| 51 | } |
| 52 | } |
| 53 | /** |
| 54 | * Create a config used to open a dictionary. |
| 55 | * |
| 56 | * pspell_config_create has a very similar syntax to |
| 57 | * pspell_new. In fact, using |
| 58 | * pspell_config_create immediately followed by |
| 59 | * pspell_new_config will produce the exact same result. |
| 60 | * However, after creating a new config, you can also use |
| 61 | * pspell_config_* functions before calling |
| 62 | * pspell_new_config to take advantage of some |
| 63 | * advanced functionality. |
| 64 | * |
| 65 | * For more information and examples, check out inline manual pspell |
| 66 | * website:http://aspell.net/. |
| 67 | * |
| 68 | * @param string $language The language parameter is the language code which consists of the |
| 69 | * two letter ISO 639 language code and an optional two letter ISO |
| 70 | * 3166 country code after a dash or underscore. |
| 71 | * @param string $spelling The spelling parameter is the requested spelling for languages |
| 72 | * with more than one spelling such as English. Known values are |
| 73 | * 'american', 'british', and 'canadian'. |
| 74 | * @param string $jargon The jargon parameter contains extra information to distinguish |
| 75 | * two different words lists that have the same language and |
| 76 | * spelling parameters. |
| 77 | * @param string $encoding The encoding parameter is the encoding that words are expected to |
| 78 | * be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r', |
| 79 | * 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned |
| 80 | * 32'. This parameter is largely untested, so be careful when |
| 81 | * using. |
| 82 | * @return int Returns a pspell config identifier. |
| 83 | * @throws PspellException |
| 84 | * |
| 85 | */ |
| 86 | function pspell_config_create(string $language, string $spelling = null, string $jargon = null, string $encoding = null): int |
| 87 | { |
| 88 | error_clear_last(); |
| 89 | if ($encoding !== null) { |
| 90 | $result = \pspell_config_create($language, $spelling, $jargon, $encoding); |
| 91 | } elseif ($jargon !== null) { |
| 92 | $result = \pspell_config_create($language, $spelling, $jargon); |
| 93 | } elseif ($spelling !== null) { |
| 94 | $result = \pspell_config_create($language, $spelling); |
| 95 | } else { |
| 96 | $result = \pspell_config_create($language); |
| 97 | } |
| 98 | if ($result === \false) { |
| 99 | throw PspellException::createFromPhpError(); |
| 100 | } |
| 101 | return $result; |
| 102 | } |
| 103 | /** |
| 104 | * This function is |
| 105 | * currently not documented; only its argument list is available. |
| 106 | * |
| 107 | * |
| 108 | * @param int $conf |
| 109 | * @param string $directory |
| 110 | * @throws PspellException |
| 111 | * |
| 112 | */ |
| 113 | function pspell_config_data_dir(int $conf, string $directory): void |
| 114 | { |
| 115 | error_clear_last(); |
| 116 | $result = \pspell_config_data_dir($conf, $directory); |
| 117 | if ($result === \false) { |
| 118 | throw PspellException::createFromPhpError(); |
| 119 | } |
| 120 | } |
| 121 | /** |
| 122 | * This function is |
| 123 | * currently not documented; only its argument list is available. |
| 124 | * |
| 125 | * |
| 126 | * @param int $conf |
| 127 | * @param string $directory |
| 128 | * @throws PspellException |
| 129 | * |
| 130 | */ |
| 131 | function pspell_config_dict_dir(int $conf, string $directory): void |
| 132 | { |
| 133 | error_clear_last(); |
| 134 | $result = \pspell_config_dict_dir($conf, $directory); |
| 135 | if ($result === \false) { |
| 136 | throw PspellException::createFromPhpError(); |
| 137 | } |
| 138 | } |
| 139 | /** |
| 140 | * |
| 141 | * |
| 142 | * @param int $dictionary_link |
| 143 | * @param int $n Words less than n characters will be skipped. |
| 144 | * @throws PspellException |
| 145 | * |
| 146 | */ |
| 147 | function pspell_config_ignore(int $dictionary_link, int $n): void |
| 148 | { |
| 149 | error_clear_last(); |
| 150 | $result = \pspell_config_ignore($dictionary_link, $n); |
| 151 | if ($result === \false) { |
| 152 | throw PspellException::createFromPhpError(); |
| 153 | } |
| 154 | } |
| 155 | /** |
| 156 | * |
| 157 | * |
| 158 | * @param int $dictionary_link |
| 159 | * @param int $mode The mode parameter is the mode in which spellchecker will work. |
| 160 | * There are several modes available: |
| 161 | * |
| 162 | * |
| 163 | * |
| 164 | * PSPELL_FAST - Fast mode (least number of |
| 165 | * suggestions) |
| 166 | * |
| 167 | * |
| 168 | * |
| 169 | * |
| 170 | * PSPELL_NORMAL - Normal mode (more suggestions) |
| 171 | * |
| 172 | * |
| 173 | * |
| 174 | * |
| 175 | * PSPELL_BAD_SPELLERS - Slow mode (a lot of |
| 176 | * suggestions) |
| 177 | * |
| 178 | * |
| 179 | * |
| 180 | * @throws PspellException |
| 181 | * |
| 182 | */ |
| 183 | function pspell_config_mode(int $dictionary_link, int $mode): void |
| 184 | { |
| 185 | error_clear_last(); |
| 186 | $result = \pspell_config_mode($dictionary_link, $mode); |
| 187 | if ($result === \false) { |
| 188 | throw PspellException::createFromPhpError(); |
| 189 | } |
| 190 | } |
| 191 | /** |
| 192 | * Set a file that contains personal wordlist. The personal wordlist will be |
| 193 | * loaded and used in addition to the standard one after you call |
| 194 | * pspell_new_config. The file is also the file where |
| 195 | * pspell_save_wordlist will save personal wordlist to. |
| 196 | * |
| 197 | * pspell_config_personal should be used on a config |
| 198 | * before calling pspell_new_config. |
| 199 | * |
| 200 | * @param int $dictionary_link |
| 201 | * @param string $file The personal wordlist. If the file does not exist, it will be created. |
| 202 | * The file should be writable by whoever PHP runs as (e.g. nobody). |
| 203 | * @throws PspellException |
| 204 | * |
| 205 | */ |
| 206 | function pspell_config_personal(int $dictionary_link, string $file): void |
| 207 | { |
| 208 | error_clear_last(); |
| 209 | $result = \pspell_config_personal($dictionary_link, $file); |
| 210 | if ($result === \false) { |
| 211 | throw PspellException::createFromPhpError(); |
| 212 | } |
| 213 | } |
| 214 | /** |
| 215 | * Set a file that contains replacement pairs. |
| 216 | * |
| 217 | * The replacement pairs improve the quality of the spellchecker. When a word |
| 218 | * is misspelled, and a proper suggestion was not found in the list, |
| 219 | * pspell_store_replacement can be used to store a |
| 220 | * replacement pair and then pspell_save_wordlist to |
| 221 | * save the wordlist along with the replacement pairs. |
| 222 | * |
| 223 | * pspell_config_repl should be used on a config |
| 224 | * before calling pspell_new_config. |
| 225 | * |
| 226 | * @param int $dictionary_link |
| 227 | * @param string $file The file should be writable by whoever PHP runs as (e.g. nobody). |
| 228 | * @throws PspellException |
| 229 | * |
| 230 | */ |
| 231 | function pspell_config_repl(int $dictionary_link, string $file): void |
| 232 | { |
| 233 | error_clear_last(); |
| 234 | $result = \pspell_config_repl($dictionary_link, $file); |
| 235 | if ($result === \false) { |
| 236 | throw PspellException::createFromPhpError(); |
| 237 | } |
| 238 | } |
| 239 | /** |
| 240 | * This function determines whether run-together words will be treated as |
| 241 | * legal compounds. That is, "thecat" will be a legal compound, although |
| 242 | * there should be a space between the two words. Changing this setting only |
| 243 | * affects the results returned by pspell_check; |
| 244 | * pspell_suggest will still return suggestions. |
| 245 | * |
| 246 | * pspell_config_runtogether should be used on a config |
| 247 | * before calling pspell_new_config. |
| 248 | * |
| 249 | * @param int $dictionary_link |
| 250 | * @param bool $flag TRUE if run-together words should be treated as legal compounds, |
| 251 | * FALSE otherwise. |
| 252 | * @throws PspellException |
| 253 | * |
| 254 | */ |
| 255 | function pspell_config_runtogether(int $dictionary_link, bool $flag): void |
| 256 | { |
| 257 | error_clear_last(); |
| 258 | $result = \pspell_config_runtogether($dictionary_link, $flag); |
| 259 | if ($result === \false) { |
| 260 | throw PspellException::createFromPhpError(); |
| 261 | } |
| 262 | } |
| 263 | /** |
| 264 | * pspell_config_save_repl determines whether |
| 265 | * pspell_save_wordlist will save the replacement pairs |
| 266 | * along with the wordlist. Usually there is no need to use this function |
| 267 | * because if pspell_config_repl is used, the |
| 268 | * replacement pairs will be saved by |
| 269 | * pspell_save_wordlist anyway, and if it is not, |
| 270 | * the replacement pairs will not be saved. |
| 271 | * |
| 272 | * pspell_config_save_repl should be used on a config |
| 273 | * before calling pspell_new_config. |
| 274 | * |
| 275 | * @param int $dictionary_link |
| 276 | * @param bool $flag TRUE if replacement pairs should be saved, FALSE otherwise. |
| 277 | * @throws PspellException |
| 278 | * |
| 279 | */ |
| 280 | function pspell_config_save_repl(int $dictionary_link, bool $flag): void |
| 281 | { |
| 282 | error_clear_last(); |
| 283 | $result = \pspell_config_save_repl($dictionary_link, $flag); |
| 284 | if ($result === \false) { |
| 285 | throw PspellException::createFromPhpError(); |
| 286 | } |
| 287 | } |
| 288 | /** |
| 289 | * |
| 290 | * |
| 291 | * @param int $config The config parameter is the one returned by |
| 292 | * pspell_config_create when the config was created. |
| 293 | * @return int Returns a dictionary link identifier on success. |
| 294 | * @throws PspellException |
| 295 | * |
| 296 | */ |
| 297 | function pspell_new_config(int $config): int |
| 298 | { |
| 299 | error_clear_last(); |
| 300 | $result = \pspell_new_config($config); |
| 301 | if ($result === \false) { |
| 302 | throw PspellException::createFromPhpError(); |
| 303 | } |
| 304 | return $result; |
| 305 | } |
| 306 | /** |
| 307 | * pspell_new opens up a new dictionary and |
| 308 | * returns the dictionary link identifier for use in other pspell |
| 309 | * functions. |
| 310 | * |
| 311 | * For more information and examples, check out inline manual pspell |
| 312 | * website:http://aspell.net/. |
| 313 | * |
| 314 | * @param string $language The language parameter is the language code which consists of the |
| 315 | * two letter ISO 639 language code and an optional two letter ISO |
| 316 | * 3166 country code after a dash or underscore. |
| 317 | * @param string $spelling The spelling parameter is the requested spelling for languages |
| 318 | * with more than one spelling such as English. Known values are |
| 319 | * 'american', 'british', and 'canadian'. |
| 320 | * @param string $jargon The jargon parameter contains extra information to distinguish |
| 321 | * two different words lists that have the same language and |
| 322 | * spelling parameters. |
| 323 | * @param string $encoding The encoding parameter is the encoding that words are expected to |
| 324 | * be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r', |
| 325 | * 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned |
| 326 | * 32'. This parameter is largely untested, so be careful when |
| 327 | * using. |
| 328 | * @param int $mode The mode parameter is the mode in which spellchecker will work. |
| 329 | * There are several modes available: |
| 330 | * |
| 331 | * |
| 332 | * |
| 333 | * PSPELL_FAST - Fast mode (least number of |
| 334 | * suggestions) |
| 335 | * |
| 336 | * |
| 337 | * |
| 338 | * |
| 339 | * PSPELL_NORMAL - Normal mode (more suggestions) |
| 340 | * |
| 341 | * |
| 342 | * |
| 343 | * |
| 344 | * PSPELL_BAD_SPELLERS - Slow mode (a lot of |
| 345 | * suggestions) |
| 346 | * |
| 347 | * |
| 348 | * |
| 349 | * |
| 350 | * PSPELL_RUN_TOGETHER - Consider run-together words |
| 351 | * as legal compounds. That is, "thecat" will be a legal compound, |
| 352 | * although there should be a space between the two words. Changing this |
| 353 | * setting only affects the results returned by |
| 354 | * pspell_check; pspell_suggest |
| 355 | * will still return suggestions. |
| 356 | * |
| 357 | * |
| 358 | * |
| 359 | * Mode is a bitmask constructed from different constants listed above. |
| 360 | * However, PSPELL_FAST, |
| 361 | * PSPELL_NORMAL and |
| 362 | * PSPELL_BAD_SPELLERS are mutually exclusive, so you |
| 363 | * should select only one of them. |
| 364 | * @return int Returns the dictionary link identifier on success. |
| 365 | * @throws PspellException |
| 366 | * |
| 367 | */ |
| 368 | function pspell_new(string $language, string $spelling = null, string $jargon = null, string $encoding = null, int $mode = 0): int |
| 369 | { |
| 370 | error_clear_last(); |
| 371 | if ($mode !== 0) { |
| 372 | $result = \pspell_new($language, $spelling, $jargon, $encoding, $mode); |
| 373 | } elseif ($encoding !== null) { |
| 374 | $result = \pspell_new($language, $spelling, $jargon, $encoding); |
| 375 | } elseif ($jargon !== null) { |
| 376 | $result = \pspell_new($language, $spelling, $jargon); |
| 377 | } elseif ($spelling !== null) { |
| 378 | $result = \pspell_new($language, $spelling); |
| 379 | } else { |
| 380 | $result = \pspell_new($language); |
| 381 | } |
| 382 | if ($result === \false) { |
| 383 | throw PspellException::createFromPhpError(); |
| 384 | } |
| 385 | return $result; |
| 386 | } |
| 387 | /** |
| 388 | * |
| 389 | * |
| 390 | * @param int $dictionary_link A dictionary link identifier opened with |
| 391 | * pspell_new_personal. |
| 392 | * @throws PspellException |
| 393 | * |
| 394 | */ |
| 395 | function pspell_save_wordlist(int $dictionary_link): void |
| 396 | { |
| 397 | error_clear_last(); |
| 398 | $result = \pspell_save_wordlist($dictionary_link); |
| 399 | if ($result === \false) { |
| 400 | throw PspellException::createFromPhpError(); |
| 401 | } |
| 402 | } |
| 403 | /** |
| 404 | * |
| 405 | * |
| 406 | * @param int $dictionary_link A dictionary link identifier, opened with |
| 407 | * pspell_new_personal |
| 408 | * @param string $misspelled The misspelled word. |
| 409 | * @param string $correct The fixed spelling for the misspelled word. |
| 410 | * @throws PspellException |
| 411 | * |
| 412 | */ |
| 413 | function pspell_store_replacement(int $dictionary_link, string $misspelled, string $correct): void |
| 414 | { |
| 415 | error_clear_last(); |
| 416 | $result = \pspell_store_replacement($dictionary_link, $misspelled, $correct); |
| 417 | if ($result === \false) { |
| 418 | throw PspellException::createFromPhpError(); |
| 419 | } |
| 420 | } |
| 421 |