On 27 June 2018 at 16:24, Michał Brzuchalski <mic...@brzuchalski.com> wrote:
> There is also one more thing I can think of. If __equals and __compareTo > methods > don't have any restrictions for $other parameter typehint then I'll be able > to declare > Foo { > public function __compareTo(int $other): int {} > } > and will get some error on > new Foo() == new DateTime('now'); > This can already happen with other magic methods. For instance: class A { public function __set(int $foo, int $bar) {} } $a = new A; $a->test = 42; # TypeError: Argument 1 passed to A::__set() must be of the type int, string given As long as the implementation correctly unwinds the stack when a Throwable is encountered (__toString *can't* cope with this, and bails out the engine), I don't think this is a problem. Regards, -- Rowan Collins [IMSoP]