Skip to content

Commit

Permalink
Fix a deprecation warning (PHP 8.1 compatibility)
Browse files Browse the repository at this point in the history
Sometimes one of the `$optionTextValues` could be `null`. And in PHP 8 `Passing null to parameter Smile-SA#1 ($string) of type string is deprecated`. So I suggest to explicitly cast all values to string.
  • Loading branch information
vsushkov authored Apr 21, 2022
1 parent 635635a commit 2a3bd16
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function prepareIndexValue($attributeId, $storeId, $value)
$optionTextFieldName = $this->getOptionTextFieldName($attributeCode);
$optionTextValues = $this->getIndexOptionsText($attributeId, $storeId, $value);
// Filter empty values. Not using array_filter here because it could remove "0" string from values.
$optionTextValues = array_diff(array_map('trim', $optionTextValues), ['', null, false]);
$optionTextValues = array_diff(array_map('trim', array_map('strval', $optionTextValues)), ['', null, false]);
$optionTextValues = array_values($optionTextValues);
$values[$optionTextFieldName] = $optionTextValues;
}
Expand Down

0 comments on commit 2a3bd16

Please sign in to comment.