note 78533 deleted from language.oop5.typehinting by cmb
| From: | cmb@php.net | Date: | Sat, 10 Dec 2016 11:52:32 +0000 |
| Subject: | note 78533 deleted from language.oop5.typehinting by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208444@lists.php.net to get a copy of this message | ||
Note Submitter: Jazz
----
To Nikivich and Edorian:
There are many times when you would use an equals() method other than to find out if the two objects
are the same object. Think of all the primitive wrapper classes in Java, for example -- if you
create two new Integer()'s with identical values, equals() returns true, even though they are
two different objects. There would be no reason to allow someone to perform an equals() between an
Integer and, say, a GregorianCalendar -- it just doesn't make sense. In Java you would attempt
this and probably get a ClassCastException, but in PHP no such facility exists, so the best way to
prevent this would be through type hinting.
The point Nicholas was making is that you can't specify a stricter type hint on an inherited
method, and despite your arguments, that would be a truly useful thing to be able to do.
(True overloading would be a better way, IMHO, but *shrug*)