note 66153 added to language.oop5.typehinting
| From: | mega-squall at caramail dot com | Date: | Tue, 16 May 2006 07:11:51 +0000 |
| Subject: | note 66153 added to language.oop5.typehinting | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111359@lists.php.net to get a copy of this message | ||
Type hinting cannot be used with array of instances of a given class. When submited to PHP Team,
idea got this answer :
" That's impossible and never will be. But you can do that more or less yourself. Derive a
class that implements ArrayAccess or reuse ArrayObject/ArrayIterator. And overload its offsetSet().
In the method body you add the check to ensure only what you want can go in. Now if that class
accepts only B's (B beeing an examble classname, ndla) you may call it ArrayOfB and the use
ArrayOfB as you typehint. "
This is obviously reaching the limit between "typing" and "type hinting" ...
----
Server IP: 195.221.21.36
Probable Submitter: 212.198.12.136
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting.php
Edit -- http://master.php.net/note/edit/66153
Del: integrated -- http://master.php.net/note/delete/66153/integrated
Del: useless -- http://master.php.net/note/delete/66153/useless
Del: bad code -- http://master.php.net/note/delete/66153/bad+code
Del: spam -- http://master.php.net/note/delete/66153/spam
Del: non-english -- http://master.php.net/note/delete/66153/non-english
Del: in docs -- http://master.php.net/note/delete/66153/in+docs
Del: other reasons-- http://master.php.net/note/delete/66153
Reject -- http://master.php.net/note/reject/66153
Search -- http://master.php.net/manage/user-notes.php