1
It seems to me that in java there is a way to make Casts to make a particular object instance of another.
Example:
MyClass variable = (MyClass) my_other_class;
In php it is possible to make type cases, and even for object, which in the ALWAYS case is the stdClass
.
Example:
$int = 1;
$object = (object) $int;
$array = (array) $int;
$str = (string) $int;
Now if I have, for example, a class I define and want to give a cast
of any value to her, 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?