You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been running development with PHP8.2 to iron out any problems well in advance of deploying it, and hit this one. I know it's only a deprecation message, but it will become a real error over time, and is presumably not intended.
It's from a NULL value in a field in the object being passed to Spyc::YAMLDump, e.g.
echo Spyc::YAMLDump((object)['test'=>NULL]);
The code clearly intends to replace NULL with the string 'null', but prior to that it passes it to trim() as if it were already a string.
If the value is a bool, it also passes that to trim() but that doesn't seem to result in a deprecation message, nevertheless is not intended.
Personally, I'd move the bool and null transforms before the trim; use if else and is_null, as in...
if ($value === array()) {
$value = '[ ]';
} else if (is_bool($value)) {
$value = $value ? "true" : "false";
} else if (is_null($value)) {
$value = 'null';
} else if ($value === "") {
$value = '""';
} else if (self::isTranslationWord($value)) {
$value = $this->_doLiteralBlock($value, $indent);
} else if (trim ($value) != $value) {
$value = $this->_doLiteralBlock($value,$indent);
}
The text was updated successfully, but these errors were encountered:
Thank you for your library.
I've been running development with PHP8.2 to iron out any problems well in advance of deploying it, and hit this one. I know it's only a deprecation message, but it will become a real error over time, and is presumably not intended.
It's from a NULL value in a field in the object being passed to Spyc::YAMLDump, e.g.
The code clearly intends to replace NULL with the string 'null', but prior to that it passes it to trim() as if it were already a string.
If the value is a bool, it also passes that to trim() but that doesn't seem to result in a deprecation message, nevertheless is not intended.
Personally, I'd move the bool and null transforms before the trim; use if else and is_null, as in...
The text was updated successfully, but these errors were encountered: