Files
apache
wp-content
mu-plugins
plugins
activitypub
audioigniter
authldap
companion-auto-update
gitium
gp-premium
jetpack-protect
menu-icons
rss-importer
simple-local-avatars
smtp-mailer
two-factor
w3-total-cache
wp-piwik
wp-webauthn
blocks
css
js
languages
wp-webauthn-vendor
beberlei
brick
composer
fgrosse
league
nyholm
psr
ramsey
spomky-labs
symfony
thecodingmachine
safe
deprecated
generated
Exceptions
apache.php
apcu.php
array.php
bzip2.php
calendar.php
classobj.php
com.php
cubrid.php
curl.php
datetime.php
dir.php
eio.php
errorfunc.php
exec.php
fileinfo.php
filesystem.php
filter.php
fpm.php
ftp.php
funchand.php
functionsList.php
gmp.php
gnupg.php
hash.php
ibase.php
ibmDb2.php
iconv.php
image.php
imap.php
info.php
ingres-ii.php
inotify.php
json.php
ldap.php
libxml.php
lzf.php
mailparse.php
mbstring.php
misc.php
msql.php
mysql.php
mysqli.php
mysqlndMs.php
mysqlndQc.php
network.php
oci8.php
opcache.php
openssl.php
outcontrol.php
password.php
pcntl.php
pcre.php
pdf.php
pgsql.php
posix.php
ps.php
pspell.php
readline.php
rpminfo.php
rrd.php
sem.php
session.php
shmop.php
simplexml.php
sockets.php
sodium.php
solr.php
spl.php
sqlsrv.php
ssdeep.php
ssh2.php
stream.php
strings.php
swoole.php
uodbc.php
uopz.php
url.php
var.php
xdiff.php
xml.php
xmlrpc.php
yaml.php
yaz.php
zip.php
zlib.php
lib
LICENSE
README.md
composer.json
rector-migrate-0.7.php
web-auth
web-token
autoload.php
LICENSE
readme.txt
wp-webauthn.php
wwa-admin-content.php
wwa-ajax.php
wwa-compatibility.php
wwa-functions.php
wwa-menus.php
wwa-profile-content.php
wwa-shortcodes.php
wwa-version.php
index.php
themes
upgrade-temp-backup
w3tc-config
index.php
.gitignore
htaccess
php.ini

452 lines
12 KiB
PHP

<?php
namespace Safe;
use Safe\Exceptions\PspellException;
/**
*
*
* @param int $dictionary_link
* @param string $word The added word.
* @throws PspellException
*
*/
function pspell_add_to_personal(int $dictionary_link, string $word): void
{
error_clear_last();
$result = \pspell_add_to_personal($dictionary_link, $word);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $dictionary_link
* @param string $word The added word.
* @throws PspellException
*
*/
function pspell_add_to_session(int $dictionary_link, string $word): void
{
error_clear_last();
$result = \pspell_add_to_session($dictionary_link, $word);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $dictionary_link
* @throws PspellException
*
*/
function pspell_clear_session(int $dictionary_link): void
{
error_clear_last();
$result = \pspell_clear_session($dictionary_link);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
* Create a config used to open a dictionary.
*
* pspell_config_create has a very similar syntax to
* pspell_new. In fact, using
* pspell_config_create immediately followed by
* pspell_new_config will produce the exact same result.
* However, after creating a new config, you can also use
* pspell_config_* functions before calling
* pspell_new_config to take advantage of some
* advanced functionality.
*
* For more information and examples, check out inline manual pspell
* website:http://aspell.net/.
*
* @param string $language The language parameter is the language code which consists of the
* two letter ISO 639 language code and an optional two letter ISO
* 3166 country code after a dash or underscore.
* @param string $spelling The spelling parameter is the requested spelling for languages
* with more than one spelling such as English. Known values are
* 'american', 'british', and 'canadian'.
* @param string $jargon The jargon parameter contains extra information to distinguish
* two different words lists that have the same language and
* spelling parameters.
* @param string $encoding The encoding parameter is the encoding that words are expected to
* be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r',
* 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned
* 32'. This parameter is largely untested, so be careful when
* using.
* @return int Returns a pspell config identifier.
* @throws PspellException
*
*/
function pspell_config_create(string $language, string $spelling = null, string $jargon = null, string $encoding = null): int
{
error_clear_last();
if ($encoding !== null) {
$result = \pspell_config_create($language, $spelling, $jargon, $encoding);
} elseif ($jargon !== null) {
$result = \pspell_config_create($language, $spelling, $jargon);
} elseif ($spelling !== null) {
$result = \pspell_config_create($language, $spelling);
} else {
$result = \pspell_config_create($language);
}
if ($result === false) {
throw PspellException::createFromPhpError();
}
return $result;
}
/**
* This function is
* currently not documented; only its argument list is available.
*
*
* @param int $conf
* @param string $directory
* @throws PspellException
*
*/
function pspell_config_data_dir(int $conf, string $directory): void
{
error_clear_last();
$result = \pspell_config_data_dir($conf, $directory);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
* This function is
* currently not documented; only its argument list is available.
*
*
* @param int $conf
* @param string $directory
* @throws PspellException
*
*/
function pspell_config_dict_dir(int $conf, string $directory): void
{
error_clear_last();
$result = \pspell_config_dict_dir($conf, $directory);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $dictionary_link
* @param int $n Words less than n characters will be skipped.
* @throws PspellException
*
*/
function pspell_config_ignore(int $dictionary_link, int $n): void
{
error_clear_last();
$result = \pspell_config_ignore($dictionary_link, $n);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $dictionary_link
* @param int $mode The mode parameter is the mode in which spellchecker will work.
* There are several modes available:
*
*
*
* PSPELL_FAST - Fast mode (least number of
* suggestions)
*
*
*
*
* PSPELL_NORMAL - Normal mode (more suggestions)
*
*
*
*
* PSPELL_BAD_SPELLERS - Slow mode (a lot of
* suggestions)
*
*
*
* @throws PspellException
*
*/
function pspell_config_mode(int $dictionary_link, int $mode): void
{
error_clear_last();
$result = \pspell_config_mode($dictionary_link, $mode);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
* Set a file that contains personal wordlist. The personal wordlist will be
* loaded and used in addition to the standard one after you call
* pspell_new_config. The file is also the file where
* pspell_save_wordlist will save personal wordlist to.
*
* pspell_config_personal should be used on a config
* before calling pspell_new_config.
*
* @param int $dictionary_link
* @param string $file The personal wordlist. If the file does not exist, it will be created.
* The file should be writable by whoever PHP runs as (e.g. nobody).
* @throws PspellException
*
*/
function pspell_config_personal(int $dictionary_link, string $file): void
{
error_clear_last();
$result = \pspell_config_personal($dictionary_link, $file);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
* Set a file that contains replacement pairs.
*
* The replacement pairs improve the quality of the spellchecker. When a word
* is misspelled, and a proper suggestion was not found in the list,
* pspell_store_replacement can be used to store a
* replacement pair and then pspell_save_wordlist to
* save the wordlist along with the replacement pairs.
*
* pspell_config_repl should be used on a config
* before calling pspell_new_config.
*
* @param int $dictionary_link
* @param string $file The file should be writable by whoever PHP runs as (e.g. nobody).
* @throws PspellException
*
*/
function pspell_config_repl(int $dictionary_link, string $file): void
{
error_clear_last();
$result = \pspell_config_repl($dictionary_link, $file);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
* This function determines whether run-together words will be treated as
* legal compounds. That is, "thecat" will be a legal compound, although
* there should be a space between the two words. Changing this setting only
* affects the results returned by pspell_check;
* pspell_suggest will still return suggestions.
*
* pspell_config_runtogether should be used on a config
* before calling pspell_new_config.
*
* @param int $dictionary_link
* @param bool $flag TRUE if run-together words should be treated as legal compounds,
* FALSE otherwise.
* @throws PspellException
*
*/
function pspell_config_runtogether(int $dictionary_link, bool $flag): void
{
error_clear_last();
$result = \pspell_config_runtogether($dictionary_link, $flag);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
* pspell_config_save_repl determines whether
* pspell_save_wordlist will save the replacement pairs
* along with the wordlist. Usually there is no need to use this function
* because if pspell_config_repl is used, the
* replacement pairs will be saved by
* pspell_save_wordlist anyway, and if it is not,
* the replacement pairs will not be saved.
*
* pspell_config_save_repl should be used on a config
* before calling pspell_new_config.
*
* @param int $dictionary_link
* @param bool $flag TRUE if replacement pairs should be saved, FALSE otherwise.
* @throws PspellException
*
*/
function pspell_config_save_repl(int $dictionary_link, bool $flag): void
{
error_clear_last();
$result = \pspell_config_save_repl($dictionary_link, $flag);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $config The config parameter is the one returned by
* pspell_config_create when the config was created.
* @return int Returns a dictionary link identifier on success.
* @throws PspellException
*
*/
function pspell_new_config(int $config): int
{
error_clear_last();
$result = \pspell_new_config($config);
if ($result === false) {
throw PspellException::createFromPhpError();
}
return $result;
}
/**
* pspell_new opens up a new dictionary and
* returns the dictionary link identifier for use in other pspell
* functions.
*
* For more information and examples, check out inline manual pspell
* website:http://aspell.net/.
*
* @param string $language The language parameter is the language code which consists of the
* two letter ISO 639 language code and an optional two letter ISO
* 3166 country code after a dash or underscore.
* @param string $spelling The spelling parameter is the requested spelling for languages
* with more than one spelling such as English. Known values are
* 'american', 'british', and 'canadian'.
* @param string $jargon The jargon parameter contains extra information to distinguish
* two different words lists that have the same language and
* spelling parameters.
* @param string $encoding The encoding parameter is the encoding that words are expected to
* be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r',
* 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned
* 32'. This parameter is largely untested, so be careful when
* using.
* @param int $mode The mode parameter is the mode in which spellchecker will work.
* There are several modes available:
*
*
*
* PSPELL_FAST - Fast mode (least number of
* suggestions)
*
*
*
*
* PSPELL_NORMAL - Normal mode (more suggestions)
*
*
*
*
* PSPELL_BAD_SPELLERS - Slow mode (a lot of
* suggestions)
*
*
*
*
* PSPELL_RUN_TOGETHER - Consider run-together words
* as legal compounds. That is, "thecat" will be a legal compound,
* although there should be a space between the two words. Changing this
* setting only affects the results returned by
* pspell_check; pspell_suggest
* will still return suggestions.
*
*
*
* Mode is a bitmask constructed from different constants listed above.
* However, PSPELL_FAST,
* PSPELL_NORMAL and
* PSPELL_BAD_SPELLERS are mutually exclusive, so you
* should select only one of them.
* @return int Returns the dictionary link identifier on success.
* @throws PspellException
*
*/
function pspell_new(string $language, string $spelling = null, string $jargon = null, string $encoding = null, int $mode = 0): int
{
error_clear_last();
if ($mode !== 0) {
$result = \pspell_new($language, $spelling, $jargon, $encoding, $mode);
} elseif ($encoding !== null) {
$result = \pspell_new($language, $spelling, $jargon, $encoding);
} elseif ($jargon !== null) {
$result = \pspell_new($language, $spelling, $jargon);
} elseif ($spelling !== null) {
$result = \pspell_new($language, $spelling);
} else {
$result = \pspell_new($language);
}
if ($result === false) {
throw PspellException::createFromPhpError();
}
return $result;
}
/**
*
*
* @param int $dictionary_link A dictionary link identifier opened with
* pspell_new_personal.
* @throws PspellException
*
*/
function pspell_save_wordlist(int $dictionary_link): void
{
error_clear_last();
$result = \pspell_save_wordlist($dictionary_link);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}
/**
*
*
* @param int $dictionary_link A dictionary link identifier, opened with
* pspell_new_personal
* @param string $misspelled The misspelled word.
* @param string $correct The fixed spelling for the misspelled word.
* @throws PspellException
*
*/
function pspell_store_replacement(int $dictionary_link, string $misspelled, string $correct): void
{
error_clear_last();
$result = \pspell_store_replacement($dictionary_link, $misspelled, $correct);
if ($result === false) {
throw PspellException::createFromPhpError();
}
}