note 73538 deleted from language.oop5.typehinting by cmb
| From: | cmb@php.net | Date: | Sat, 10 Dec 2016 11:51:46 +0000 |
| Subject: | note 73538 deleted from language.oop5.typehinting by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208442@lists.php.net to get a copy of this message | ||
Note Submitter: ldebuyst->brutele.be
----
In reply to Nikivich and Edorian:
Although it isn't quite clear from his post, I believe that the point nicholas is trying to
make is that, if you typehint an abstract function, you MUST use that same typehint for all classes
extending the abstract class.
As his example shows, if you typehint (Object $object), then you must use the exact same typehint
in the extending class. Using the typehint (Table $table) or (Chair $chair) will give fatal errors,
even if Table and Chair are subclasses of Object.
In other words, type hinting allows for descendants, as caliban at darklock dot com has shown,
except when you're subclassing.
See http://bugs.php.net/bug.php?id=36601 for a
bit more info. Flagged as wontfix, though, so something to keep in mind.