Why is it possible to create an interface without specifying a return type? Why doesn't this make this interface unusable?
This makes it more clear:
Interface run
{
public function getInteger();
}
class MyString implements run
{
public function myNumber()
{
}
public function getInteger()
{
return "Not a number";
}
}
In Java every Interface has a return type like Integer
, String
or Void
I know that PHP is unfortunately a loosely typed language but isn't there a solution to that problem?
Is it possible to define an Interface with a return type like Integer
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…