Type casting in PHP works much as it does in C
The name of the desired type is written in parentheses before
$arr1 = array(1, 2, 3);
$arr2 = (string) $arr1;
Array to object
You can call an array item like object property if you type cast array to object.
$arr = array('senderId' => 10);
$obj = (object) $arr;
stdClass is the default PHP object
stdClass has no properties,
methods or parent.
It does not support magic methods, and implements no interfaces.
When you cast a scalar or array as Object, you get an instance of stdClass.
$obj = (object) array();
$obj = new stdClass();
$obj->key1 = "value1";
$obj->key2 = "value2";