note 78533 added to language.oop5.typehinting

From: Date: Tue, 16 Oct 2007 16:20:51 +0000
Subject: note 78533 added to language.oop5.typehinting
Groups: php.notes 
Request: Send a blank email to php-notes+get-131428@lists.php.net to get a copy of this message
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*) ---- Server IP: 209.41.74.194 Probable Submitter: 163.191.24.14 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php Edit -- https://master.php.net/note/edit/78533 Del: integrated -- https://master.php.net/note/delete/78533/integrated Del: useless -- https://master.php.net/note/delete/78533/useless Del: bad code -- https://master.php.net/note/delete/78533/bad+code Del: spam -- https://master.php.net/note/delete/78533/spam Del: non-english -- https://master.php.net/note/delete/78533/non-english Del: in docs -- https://master.php.net/note/delete/78533/in+docs Del: other reasons-- https://master.php.net/note/delete/78533 Reject -- https://master.php.net/note/reject/78533 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131428) next »