It seems to me that in java there is a way to make casts to make a given object instance another.
Example:
MyClass variable = (MyClass) my_other_class;
In php it is possible to do casts of types, and even for object, which in the case is ALWAYS the stdClass
.
Example:
$int = 1;
$object = (object) $int;
$array = (array) $int;
$str = (string) $int;
Now if I have, for example, a class that I defined and want to give a cast
of any value to it, it is not possible.
Example:
$arr = array();
$obj = (object) $arr; // Retorna: stdClass
$myObj = (MyObject) $arr; // Retorna: Parse Error
Is there any way to simulate this in PHP?