<?php
class Test
{
public $valor = 'testeClasse';
}
//instância do objeto
$objeto = new Test();
//array
$array['valor'] = 'testeArray';
//cast array
$saidaArray = (array) $objeto; //cast object
$saidaObject = (object) $array;
//saídas
PD9waHAKCiBjbGFzcyBUZXN0CiB7CiAgICAKICAgIHB1YmxpYyAkdmFsb3IgPSAndGVzdGVDbGFzc2UnOwogICAgCiB9CiAgIC8vaW5zdMOibmNpYSBkbyBvYmpldG8KICAgICRvYmpldG8gPSBuZXcgVGVzdCgpOwogICAgCiAgICAvL2FycmF5CiAgICAkYXJyYXlbJ3ZhbG9yJ10gPSAndGVzdGVBcnJheSc7CiAgICAKICAgIC8vY2FzdCBhcnJheQogICAgJHNhaWRhQXJyYXkgPSAoYXJyYXkpICRvYmpldG87CiAgICAvL2Nhc3Qgb2JqZWN0CiAgICAkc2FpZGFPYmplY3QgPSAob2JqZWN0KSAkYXJyYXk7CiAgICAKICAgIC8vc2HDrWRhcwogICAgcHJpbnRfcigkc2FpZGFBcnJheSk7CiAgICBwcmludF9yKCRzYWlkYU9iamVjdCk7