I have an interface like so:
interface A {
static function from($object): self;
}
In the class that implements the interface:
class B implements A {
static function from(\C $object): self{ // This is highlighted as an error
return new self();
}
}
Can I not declare a type when the interface has not declared a type?
Can I not declare a type when the interface has not declared a type?
In short: no.
As per the docs for interfaces (which seem pretty clear to me):
The class implementing the interface must use the exact same method signatures as are defined in the interface. Not doing so will result in a fatal error.
If you provided more detail as to why you think you need to do this, we could perhaps give a more helpful answer, but yer just asking a yes/no question, and the answer to that is - as I said - "no".