Skip to content

Commit

Permalink
fix: deprecated nullish value as string on PHP8.1
Browse files Browse the repository at this point in the history
M2-97 - Fixed some "Passing null to parameter of type string is deprecated" problems for PHP 8.1 compatibility (#27)
  • Loading branch information
FatchipRobert authored May 6, 2022
1 parent bb2d82d commit 77e6b3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Model/Request/SubModel/AbstractModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function toArray()
}
} else {
if (key_exists('cdata', $fieldSettings)) { // If value should be encapsulated inside CDATA tag
if (function_exists('mb_detect_encoding') && !mb_detect_encoding($fieldSettings['value'], 'UTF-8', true)) { // Check only if php mdstring extension is loaded
if (function_exists('mb_detect_encoding') && is_string($fieldSettings['value']) && !mb_detect_encoding($fieldSettings['value'], 'UTF-8', true)) { // Check only if php mdstring extension is loaded
throw new ModelException("Value of '" . $fieldName . "' has to be encoded in UTF-8");
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Service/SimpleXmlExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function addCDataChild($sName, $sValue)
*/
private function removeSpecialChars($str)
{
if (!is_string($str)) {
return '';
}

$search = ['', '´', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '¼', '½', '¾'];
$replace = ['-', "'", '<', '>', "'", "'", ',', '"', '"', '"', '"', '-', '-', '-', '-', 'TM', '1/4', '1/2', '3/4'];

Expand Down

0 comments on commit 77e6b3a

Please sign in to comment.