On 09.04.2020 at 14:41, Dan Ackroyd wrote: > On Thu, 9 Apr 2020 at 13:18, Dan Ackroyd <dan...@basereality.com> wrote: > >> It appears to be the same error case as: >> > > And that code had a mistake. Should have been: > > ``` > class A { > public function add(A $rhs) {...} > } > > class B { > public function add(A|B $rhs) {...} > } > > $a = new A; > $b = new B; > > $b->add($a); // Ok > $a->add($b); // TypeError > ```
If we'd go with (dynamic) methods, wouldn't we have to add "r"-methods (like Python does) as well? And if we did so, wouldn't we encourage misusing operator overloading for all kinds of stuff (for which it shouldn't be used, in my opinion)? -- Christoph M. Becker -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php