I have an interface in PHP
interface IDummy{
public function DoSomething();
}
I have another class that implements this interface.
class Dummy implements IDummy{
public function DoSomething(){
}
How can I type cast the Dummy Object to IDummy in PHP, so that I can call it as
$dum = new Dummy();
$instance = (IDummy)$dum;
$instance->DoSomething();
Can I do this in PHP?
Thanks and Regards
Abishek R Srikaanth
The cast is completely unnecessary. It will simply work.
And the Dummy objects will be considered an instance of IDummy if you ever check it with one of the various type hinting functions.
This works… no casting needed: