phpstan updates
This commit is contained in:
@@ -83,6 +83,9 @@ function mtParseCSV(
|
|||||||
'UTF-8',
|
'UTF-8',
|
||||||
$encoding
|
$encoding
|
||||||
);
|
);
|
||||||
|
if ($string === false) {
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($flag == 'INTERN') {
|
if ($flag == 'INTERN') {
|
||||||
// split with PHP function
|
// split with PHP function
|
||||||
|
|||||||
@@ -989,10 +989,10 @@ class Basic
|
|||||||
* @param bool $auto_check default true, if source encoding is set
|
* @param bool $auto_check default true, if source encoding is set
|
||||||
* check that the source is actually matching
|
* check that the source is actually matching
|
||||||
* to what we sav the source is
|
* to what we sav the source is
|
||||||
* @return string encoding converted string
|
* @return string|false encoding converted string
|
||||||
* @deprecated use \CoreLibs\Convert\Encoding::convertEncoding() instead
|
* @deprecated use \CoreLibs\Convert\Encoding::convertEncoding() instead
|
||||||
*/
|
*/
|
||||||
public static function convertEncoding(string $string, string $to_encoding, string $source_encoding = '', bool $auto_check = true): string
|
public static function convertEncoding(string $string, string $to_encoding, string $source_encoding = '', bool $auto_check = true): string|false
|
||||||
{
|
{
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Encoding::convertEncoding()', E_USER_DEPRECATED);
|
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Encoding::convertEncoding()', E_USER_DEPRECATED);
|
||||||
return \CoreLibs\Convert\Encoding::convertEncoding($string, $to_encoding, $source_encoding, $auto_check);
|
return \CoreLibs\Convert\Encoding::convertEncoding($string, $to_encoding, $source_encoding, $auto_check);
|
||||||
|
|||||||
@@ -56,7 +56,11 @@ class Encoding
|
|||||||
{
|
{
|
||||||
// return mb_substitute_character();
|
// return mb_substitute_character();
|
||||||
if ($return_substitute_func === true) {
|
if ($return_substitute_func === true) {
|
||||||
return mb_substitute_character();
|
// if false abort with error
|
||||||
|
if (($return = mb_substitute_character()) === false) {
|
||||||
|
return self::$mb_error_char;
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
} else {
|
} else {
|
||||||
return self::$mb_error_char;
|
return self::$mb_error_char;
|
||||||
}
|
}
|
||||||
@@ -88,7 +92,13 @@ class Encoding
|
|||||||
): array|false {
|
): array|false {
|
||||||
// convert to target encoding and convert back
|
// convert to target encoding and convert back
|
||||||
$temp = mb_convert_encoding($string, $to_encoding, $from_encoding);
|
$temp = mb_convert_encoding($string, $to_encoding, $from_encoding);
|
||||||
|
if ($temp === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$compare = mb_convert_encoding($temp, $from_encoding, $to_encoding);
|
$compare = mb_convert_encoding($temp, $from_encoding, $to_encoding);
|
||||||
|
if ($compare === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// if string does not match anymore we have a convert problem
|
// if string does not match anymore we have a convert problem
|
||||||
if ($string == $compare) {
|
if ($string == $compare) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ class Encoding
|
|||||||
* @param bool $auto_check default true, if source encoding is set
|
* @param bool $auto_check default true, if source encoding is set
|
||||||
* check that the source is actually matching
|
* check that the source is actually matching
|
||||||
* to what we sav the source is
|
* to what we sav the source is
|
||||||
* @return string encoding converted string
|
* @return string|false encoding converted string or false on error
|
||||||
*/
|
*/
|
||||||
public static function convertEncoding(
|
public static function convertEncoding(
|
||||||
string $string,
|
string $string,
|
||||||
string $to_encoding,
|
string $to_encoding,
|
||||||
string $source_encoding = '',
|
string $source_encoding = '',
|
||||||
bool $auto_check = true
|
bool $auto_check = true
|
||||||
): string {
|
): string|false {
|
||||||
// set if not given
|
// set if not given
|
||||||
if (!$source_encoding) {
|
if (!$source_encoding) {
|
||||||
$source_encoding = mb_detect_encoding($string);
|
$source_encoding = mb_detect_encoding($string);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class Email
|
|||||||
* @param string $encoding Encoding, if not set UTF-8
|
* @param string $encoding Encoding, if not set UTF-8
|
||||||
* @param bool $kv_folding If set to true and a valid encoding, do KV folding
|
* @param bool $kv_folding If set to true and a valid encoding, do KV folding
|
||||||
* @return string Correctly encoded and build email string
|
* @return string Correctly encoded and build email string
|
||||||
|
* @throws \IntlException if email name cannot be converted to UTF-8
|
||||||
*/
|
*/
|
||||||
public static function encodeEmailName(
|
public static function encodeEmailName(
|
||||||
string $email,
|
string $email,
|
||||||
@@ -52,6 +53,10 @@ class Email
|
|||||||
if ($encoding != 'UTF-8') {
|
if ($encoding != 'UTF-8') {
|
||||||
$email_name = mb_convert_encoding($email_name, $encoding, 'UTF-8');
|
$email_name = mb_convert_encoding($email_name, $encoding, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
// if we cannot transcode the name, return just the email
|
||||||
|
if ($email_name === false) {
|
||||||
|
throw new \IntlException('Cannot convert email_name to UTF-8');
|
||||||
|
}
|
||||||
$email_name =
|
$email_name =
|
||||||
mb_encode_mimeheader(
|
mb_encode_mimeheader(
|
||||||
in_array($encoding, self::$encoding_kv_allowed) && $kv_folding ?
|
in_array($encoding, self::$encoding_kv_allowed) && $kv_folding ?
|
||||||
@@ -77,6 +82,8 @@ class Email
|
|||||||
* @param bool $kv_folding If set to true and a valid encoding,
|
* @param bool $kv_folding If set to true and a valid encoding,
|
||||||
* do KV folding
|
* do KV folding
|
||||||
* @return array<string> Pos 0: Subject, Pos 1: Body
|
* @return array<string> Pos 0: Subject, Pos 1: Body
|
||||||
|
* @throws \IntlException if subject cannot be converted to UTF-8
|
||||||
|
* @throws \IntlException if body cannot be converted to UTF-8
|
||||||
*/
|
*/
|
||||||
private static function replaceContent(
|
private static function replaceContent(
|
||||||
string $subject,
|
string $subject,
|
||||||
@@ -102,6 +109,12 @@ class Email
|
|||||||
$subject = mb_convert_encoding($subject, $encoding, 'UTF-8');
|
$subject = mb_convert_encoding($subject, $encoding, 'UTF-8');
|
||||||
$body = mb_convert_encoding($body, $encoding, 'UTF-8');
|
$body = mb_convert_encoding($body, $encoding, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
if ($subject === false) {
|
||||||
|
throw new \IntlException('Cannot convert subject to UTF-8');
|
||||||
|
}
|
||||||
|
if ($body === false) {
|
||||||
|
throw new \IntlException('Cannot convert body to UTF-8');
|
||||||
|
}
|
||||||
// we need to encodde the subject
|
// we need to encodde the subject
|
||||||
$subject = mb_encode_mimeheader(
|
$subject = mb_encode_mimeheader(
|
||||||
in_array($encoding, self::$encoding_kv_allowed) && $kv_folding ?
|
in_array($encoding, self::$encoding_kv_allowed) && $kv_folding ?
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ class Curl implements Interface\RequestsInterface
|
|||||||
// for post we set POST option
|
// for post we set POST option
|
||||||
if ($type == "post") {
|
if ($type == "post") {
|
||||||
curl_setopt($handle, CURLOPT_POST, true);
|
curl_setopt($handle, CURLOPT_POST, true);
|
||||||
} elseif (!empty($type) && in_array($type, self::CUSTOM_REQUESTS)) {
|
} elseif (in_array($type, self::CUSTOM_REQUESTS)) {
|
||||||
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, strtoupper($type));
|
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, strtoupper($type));
|
||||||
}
|
}
|
||||||
// set body data if not null, will send empty [] for empty data
|
// set body data if not null, will send empty [] for empty data
|
||||||
|
|||||||
Reference in New Issue
Block a user