Re: [RFC] Type hints
| From: | Derick Rethans | Date: | Sun, 09 May 2004 10:57:26 +0000 |
| Subject: | Re: [RFC] Type hints | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9750@lists.php.net to get a copy of this message | ||
On Sun, 9 May 2004, Andi Gutmans wrote:
> I really would like to finalize this issue ASAP because it's the last
> *feature* I see for PHP 5.0. The main reason why I think we need to
> finalize it is because depending on the solution we choose, it would break
> BC if we fix it after 5.0.
> Consider the following options for a parameter with default value which
> allows null:
> MyClass $a or NULL = 5
> MyClass $a = 5 or NULL
> MyClass or NULL $a = 5
>
> I think all of these are pretty ugly and I don't feel comfortable with
> adding them to the language.
> The following (Zeev's idea) is much simpler and nicer, but I'm not 100%
> sure if this is the perfect solution:
> nullable MyClass $a = 5
null or MyClass $a = 5 ?
I've no idea what nullable is supposed to mean... (well, I do :)
I was also wondering if the following would also work:
class b extends a { }
function foo (a $obj) { }
$b = new b;
foo($b);
(ie, an inherited class also passes the hint check)
Derick