rest_sanitize_object

The timeline below displays how wordpress function rest_sanitize_object has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Converts an object-like value to an array.
 *
 * @since 5.5.0
 *
 * @param mixed $maybe_object The value being evaluated.
 * @return array Returns the object extracted from the value as an associative array.
 */
function rest_sanitize_object($maybe_object)
{
    if ('' === $maybe_object) {
        return array();
    }
    if ($maybe_object instanceof stdClass) {
        return (array) $maybe_object;
    }
    if ($maybe_object instanceof JsonSerializable) {
        $maybe_object = $maybe_object->jsonSerialize();
    }
    if (!is_array($maybe_object)) {
        return array();
    }
    return $maybe_object;
}

WordPress Version: 5.5

/**
 * Converts an object-like value to an object.
 *
 * @since 5.5.0
 *
 * @param mixed $maybe_object The value being evaluated.
 * @return array Returns the object extracted from the value.
 */
function rest_sanitize_object($maybe_object)
{
    if ('' === $maybe_object) {
        return array();
    }
    if ($maybe_object instanceof stdClass) {
        return (array) $maybe_object;
    }
    if ($maybe_object instanceof JsonSerializable) {
        $maybe_object = $maybe_object->jsonSerialize();
    }
    if (!is_array($maybe_object)) {
        return array();
    }
    return $maybe_object;
}