Though I honestly can't see why you'd want to do this (associative arrays are in essence data-only-objects) but if you insist:
Instead of casting every single array, on every single level to an object, you could use the following "trick/hack":
$object = json_decode(
json_encode(
array('some'=>array('multi'=>'Dimensional'),
'array'=>'that',
'you' => array('want' => 'to',
'turn' => 'into'),
'an' => 'object')));
This converts all arrays into instances of the stdClass, which I believe is what you wanted.
Again, I have to say: PHP is not JavaScript, and objects are far more expensive (relatively speaking) in languages like PHP, then they are in JS. I'd strongly recommend you stick with using assoc arrays if you don't need an object.
Like objects, arrays can be type-hinted: function foo (array $argument){}
If you really want to turn them into a particular instance of some class, why not change the constructor, to deal with an array:
class My_Object extends stdClass
{
public function __construct(array $params = null)
{
if (!empty($params))
{
foreach ($params as $name => $value)
{
$this->{$name} = $value;//set everything
}
}
}
}
And go on to add whatever methods you want to add to the lot
stdClassobjects.