wp_insert_post: array only. wp_update_post: array|object (?)

Array’s are technically preferred for both, but it actually doesn’t matter that much. PHP is not casting the object to an array, worpress is. wp_insert_post(), like a lot of wordpress functions, runs it’s “array” parameter through wp_parse_args() which will cast an object passed to it to an array and will always returns an array.

You should probably address it in case wordpress ever released an update where they stopped casting the object for you and PHP will throw a fatal error if you try to use an object as an array. But frankly, that casting probably isn’t super likely to be removed any time soon.

If you did want to fix it, all you would have to do is replace

wp_insert_post($object);

with

wp_insert_post(get_object_vars($object));

tech