Fix deprecated usage of string functions

[MAILPOET-4001]
This commit is contained in:
Jan Lysý
2022-01-05 16:49:28 +01:00
committed by Veljko V
parent f249b379f8
commit 492415f3ae
5 changed files with 8 additions and 8 deletions

View File

@@ -1453,7 +1453,7 @@ class DomNode implements IQuery {
* @return bool * @return bool
*/ */
function hasClass($className) { function hasClass($className) {
return ($className && preg_match('`\b'.preg_quote($className).'\b`si', $this->class)); return ($className && preg_match('`\b'.preg_quote($className).'\b`si', (string)$this->class));
} }
/** /**
@@ -1466,11 +1466,11 @@ class DomNode implements IQuery {
} }
$class = $this->class; $class = $this->class;
foreach ($className as $c) { foreach ($className as $c) {
if (!(preg_match('`\b'.preg_quote($c).'\b`si', $class) > 0)) { if (!(preg_match('`\b'.preg_quote($c).'\b`si', (string)$class) > 0)) {
$class .= ' '.$c; $class .= ' '.$c;
} }
} }
$this->class = trim($class); $this->class = trim((string)$class);
} }
/** /**

View File

@@ -39,7 +39,7 @@ class SMTPMapper {
public function getErrorFromLog($log, $subscriber) { public function getErrorFromLog($log, $subscriber) {
// extract error message from log // extract error message from log
preg_match('/!! (.*?)>>/ism', $log, $message); preg_match('/!! (.*?)>>/ism', (string)$log, $message);
if (!empty($message[1])) { if (!empty($message[1])) {
$message = $message[1]; $message = $message[1];
// remove line breaks from the message due to how logger's dump() method works // remove line breaks from the message due to how logger's dump() method works

View File

@@ -101,7 +101,7 @@ class Text {
$paragraph->remove(); $paragraph->remove();
continue; continue;
} }
$style = $paragraph->style; $style = (string)$paragraph->style;
if (!preg_match('/text-align/i', $style)) { if (!preg_match('/text-align/i', $style)) {
$style = 'text-align: left;' . $style; $style = 'text-align: left;' . $style;
} }

View File

@@ -104,13 +104,13 @@ class StylesHelper {
$textAlignment = isset($block['styles']['block']['textAlign']) ? $textAlignment = isset($block['styles']['block']['textAlign']) ?
strtolower($block['styles']['block']['textAlign']) : strtolower($block['styles']['block']['textAlign']) :
''; '';
if (preg_match('/center|right|justify/i', $textAlignment)) { if (preg_match('/center|right|justify/i', (string)$textAlignment)) {
return $block; return $block;
} }
$block['styles']['block']['textAlign'] = 'left'; $block['styles']['block']['textAlign'] = 'left';
return $block; return $block;
} }
return (preg_match('/text-align.*?[center|justify|right]/i', $block)) ? return (preg_match('/text-align.*?[center|justify|right]/i', (string)$block)) ?
$block : $block :
$block . 'text-align:left;'; $block . 'text-align:left;';
} }

View File

@@ -113,7 +113,7 @@ class Export {
throw new \Exception(__('Failed opening file for export.', 'mailpoet')); throw new \Exception(__('Failed opening file for export.', 'mailpoet'));
} }
$formatCSV = function($row) { $formatCSV = function($row) {
return '"' . str_replace('"', '\"', $row) . '"'; return '"' . str_replace('"', '\"', (string)$row) . '"';
}; };
// add UTF-8 BOM (3 bytes, hex EF BB BF) at the start of the file for // add UTF-8 BOM (3 bytes, hex EF BB BF) at the start of the file for
// Excel to automatically recognize the encoding // Excel to automatically recognize the encoding