I'd update this to:

`if (!is_scalar($value) || null === $value) {`

in order to retain the original behavior.