Re: Type hints with null default values

From: Date: Tue, 19 Oct 2004 18:22:51 +0000
Subject: Re: Type hints with null default values
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-13397@lists.php.net to get a copy of this message
Hello Christian, we've discussed this restriction before and the more i think over the issue the more i come to the conclusion that if at all we should provide this exact syntax. regards marcus Tuesday, October 19, 2004, 11:42:22 AM, you wrote: > Andi Gutmans wrote: >> So one suggestion (also made a few months ago) was that the following: >> function method(MyClass $obj = NULL); >> would mark $obj as allowing NULL parameter. > The only restrictions I see is that it makes the parameter optional as > well (something I don't consider a problem as it is probably desirable > in most cases anyway to be able to leave out an explicit null) and that > it only works if no mandatory parameter follows, e.g. > function method(MyClass $obj = null, $mandatory); > is not possible. Not a real problem either IMHO. > I still like this option more than anything else proposed here because > it doesn't add new syntax and is simple to understand ("I can leave the > parameter out then it will be null or I can pass null as I could also > have left it out instead, otherwise I need to pass an object of MyClass").

« previous php.internals (#13397) next »