Just like we do with __ToString, is there a way to define a method for casting?
$obj = (MyClass) $another_class_obj;
I mainly need type casting to enable intellisense - so I just create a type cast helper:
function castToTest($val): Test
{
return $val;
}
$test = castToTest(require("someFile.php"));
Returning from a file is kind of ugly and does not allow for type hinting, so this is a perfect example of how you can achieve intellisense by using a type cast helper.