Re: [RFC] Type hints
| From: | Stanislav Malyshev | Date: | Sun, 09 May 2004 10:57:56 +0000 |
| Subject: | Re: [RFC] Type hints | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9751@lists.php.net to get a copy of this message | ||
AG>>>AG>>nullable MyClass $a = 5
AG>>>
AG>>>I must be missing something, but why typehinted variable should have any
AG>>>default except for null anyway? If someone says "I want only MyClass
AG>>>here!", why he should be able to put 5 there?
AG>>
AG>>Well maybe it's a bad example but he can put NULL instead of 5.
Well, that was exactly my point, though not expressed explicitly:
if you can put null there, you don't need 'nullable'. If you say 'MyClass
$a', it doesn't allow null, if you say 'MyClass $a = null', it allows
null. Or, other way around, if you say 'nullable MyClass $a', it defaults
to null, otherwise it has no default. I think we should prohibit to put
any default to typehinted variables except null in any case - since it
doesn't make any sense except promoting code based on is_object checks
etc. - the exact thing we wanted to avoid with typehints.
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115