Rename MailSo\Base\Utils::FunctionExistsAndEnabled() to more logical MailSo\Base\Utils::FunctionCallable()

This commit is contained in:
the-djmaze 2022-10-17 11:16:47 +02:00
parent f3e159f2c6
commit b011d1fa0e
10 changed files with 20 additions and 20 deletions

View file

@ -23,7 +23,7 @@ abstract class HtmlUtils
public static function BuildHtml(string $sHtml, array &$aFoundCids, array &$aFoundDataURL, array &$aFoundContentLocationUrls) : string
{
$bState = true;
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors'))
if (\MailSo\Base\Utils::FunctionCallable('libxml_use_internal_errors'))
{
$bState = \libxml_use_internal_errors(true);
}
@ -86,12 +86,12 @@ abstract class HtmlUtils
$oDoc->normalizeDocument();
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_clear_errors'))
if (\MailSo\Base\Utils::FunctionCallable('libxml_clear_errors'))
{
\libxml_clear_errors();
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors'))
if (\MailSo\Base\Utils::FunctionCallable('libxml_use_internal_errors'))
{
\libxml_use_internal_errors($bState);
}

View file

@ -90,7 +90,7 @@ class Http
$sResultHeader = $this->GetServer($sServerKey, '');
if (0 === \strlen($sResultHeader) &&
\MailSo\Base\Utils::FunctionExistsAndEnabled('apache_request_headers'))
\MailSo\Base\Utils::FunctionCallable('apache_request_headers'))
{
$sHeaders = \apache_request_headers();
if (isset($sHeaders[$sHeader]))

View file

@ -749,7 +749,7 @@ abstract class Utils
{
$iResetTimer = 0;
$bValidateAction = static::FunctionExistsAndEnabled('set_time_limit');
$bValidateAction = static::FunctionCallable('set_time_limit');
}
if ($bValidateAction && $iTimeToReset < $iTime - $iResetTimer)
@ -983,10 +983,10 @@ abstract class Utils
return static::MbConvertEncoding($sStr, 'UTF-8', 'UTF7-IMAP');
}
public static function FunctionsExistAndEnabled(array $aFunctionNames) : bool
public static function FunctionsCallable(array $aFunctionNames) : bool
{
foreach ($aFunctionNames as $sFunctionName) {
if (!static::FunctionExistsAndEnabled($sFunctionName)) {
if (!static::FunctionCallable($sFunctionName)) {
return false;
}
}
@ -994,7 +994,7 @@ abstract class Utils
}
private static $disabled_functions = null;
public static function FunctionExistsAndEnabled(string $sFunctionName) : bool
public static function FunctionCallable(string $sFunctionName) : bool
{
if (null === static::$disabled_functions) {
static::$disabled_functions = \array_map('trim', \explode(',', \ini_get('disable_functions')));

View file

@ -318,7 +318,7 @@ class Message extends Part
$sHostName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
}
if (empty($sHostName) && \MailSo\Base\Utils::FunctionExistsAndEnabled('php_uname'))
if (empty($sHostName) && \MailSo\Base\Utils::FunctionCallable('php_uname'))
{
$sHostName = \php_uname('n');
}
@ -330,7 +330,7 @@ class Message extends Part
return '<'.
\MailSo\Base\Utils::Sha1Rand($sHostName.
(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? \getmypid() : '')).'@'.$sHostName.'>';
(\MailSo\Base\Utils::FunctionCallable('getmypid') ? \getmypid() : '')).'@'.$sHostName.'>';
}
public function GetRootPart() : Part

View file

@ -52,6 +52,6 @@ abstract class ConnectionSecurityType
return
(self::STARTTLS === $iSecurityType
|| (self::AUTO_DETECT === $iSecurityType && (!$bHasSupportedAuth || \MailSo\Config::$PreferStartTlsIfAutoDetect)))
&& \defined('STREAM_CRYPTO_METHOD_TLS_CLIENT') && \MailSo\Base\Utils::FunctionExistsAndEnabled('stream_socket_enable_crypto');
&& \defined('STREAM_CRYPTO_METHOD_TLS_CLIENT') && \MailSo\Base\Utils::FunctionCallable('stream_socket_enable_crypto');
}
}

View file

@ -201,7 +201,7 @@ abstract class NetClient
if ($this->rConnect)
{
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_set_timeout'))
if (\MailSo\Base\Utils::FunctionCallable('stream_set_timeout'))
{
\stream_set_timeout($this->rConnect, $this->iSocketTimeOut);
}
@ -211,7 +211,7 @@ abstract class NetClient
public function EnableCrypto(bool $insecure = false)
{
$bError = true;
if ($this->rConnect && \MailSo\Base\Utils::FunctionExistsAndEnabled('stream_socket_enable_crypto')) {
if ($this->rConnect && \MailSo\Base\Utils::FunctionCallable('stream_socket_enable_crypto')) {
$crypto_method = STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
if (\defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && OPENSSL_VERSION_NUMBER >= 0x10101000) {
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT;
@ -284,7 +284,7 @@ abstract class NetClient
public function StreamContextParams() : array
{
return $this->rConnect && \MailSo\Base\Utils::FunctionExistsAndEnabled('stream_context_get_options')
return $this->rConnect && \MailSo\Base\Utils::FunctionCallable('stream_context_get_options')
? \stream_context_get_params($this->rConnect) : false;
}

View file

@ -141,9 +141,9 @@ class Actions
$this->oLogger->Write(
'[SM:' . APP_VERSION . '][IP:'
. $oHttp->GetClientIp($this->oConfig->Get('labs', 'http_client_ip_check_proxy', false))
. '][PID:' . (\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? \getmypid() : 'unknown')
. '][PID:' . (\MailSo\Base\Utils::FunctionCallable('getmypid') ? \getmypid() : 'unknown')
. '][' . $oHttp->GetServer('SERVER_SOFTWARE', '~')
. '][' . (\MailSo\Base\Utils::FunctionExistsAndEnabled('php_sapi_name') ? \php_sapi_name() : '~')
. '][' . (\MailSo\Base\Utils::FunctionCallable('php_sapi_name') ? \php_sapi_name() : '~')
. '][Streams:' . \implode(',', \stream_get_transports())
. '][' . $oHttp->GetMethod() . ' ' . $oHttp->GetScheme() . '://' . $oHttp->GetHost(false, false) . $oHttp->GetServer('REQUEST_URI', '') . ']'
);
@ -509,7 +509,7 @@ class Actions
break;
case ('APCU' === $sDriver) &&
\MailSo\Base\Utils::FunctionsExistAndEnabled(array(
\MailSo\Base\Utils::FunctionsCallable(array(
'apcu_store', 'apcu_fetch', 'apcu_delete', 'apcu_clear_cache')):
$oDriver = new \MailSo\Cache\Drivers\APCU($sKey);

View file

@ -799,7 +799,7 @@ trait Messages
if ($bUsePhpMail)
{
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('mail'))
if (\MailSo\Base\Utils::FunctionCallable('mail'))
{
$aToCollection = $oMessage->GetTo();
if ($aToCollection && $oFrom)

View file

@ -324,7 +324,7 @@ class ActionsAdmin extends Actions
if ($oDomain->OutUsePhpMail())
{
$bSmtpResult = \MailSo\Base\Utils::FunctionExistsAndEnabled('mail');
$bSmtpResult = \MailSo\Base\Utils::FunctionCallable('mail');
if (!$bSmtpResult)
{
$sSmtpErrorDesc = 'PHP: mail() function is undefined';

View file

@ -45,7 +45,7 @@ abstract class AbstractConfig implements \JsonSerializable
$this->aData = $this->defaultValues();
$this->bUseApcCache = APP_USE_APCU_CACHE &&
\MailSo\Base\Utils::FunctionsExistAndEnabled(array('apcu_fetch', 'apcu_store'));
\MailSo\Base\Utils::FunctionsCallable(array('apcu_fetch', 'apcu_store'));
}
protected abstract function defaultValues() : array;