//object init
$object = (object) [
'propertyOne' => 'foo',
'propertyTwo' => 42,
];
$o= new stdClass();
$o->a = 'new object';
OR
$o = (object) ['a' => 'new object'];
In a variable:
$variable = (object) "lol";
$a = array('foo' => 'bar');
$o = (object) $a;
var_dump($o instanceof stdClass); // bool(true)
var_dump($o->foo); // string(3) "bar"