Re: Type hints with null default values

From: Date: Wed, 27 Oct 2004 07:27:11 +0000
Subject: Re: Type hints with null default values
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-13556@lists.php.net to get a copy of this message
Hello Cristiano, Wednesday, October 27, 2004, 2:21:03 AM, you wrote: > So reading all posts on this subject, the proposal would be: > 1) Allow null typehints > public function Compare([BaseClass] $objA, $cmpFunc); see below. > 2) Don't allow null typehints > public function Compare(BaseClass $objA, $cmpFunc); > Ex: Compare(new BaseClass(), 'func1'); > 3) Optional argument (with typehint) > public function Compare($cmpFunc, BaseClass $objA=null); This is no option because BaseClass typehint doesn't allow null and if we have a dedicated syntax for default values we don't need this. If at all this would be: 4) public function Compare($cmpFunc, [BaseClass] $objA=null); But first we need to know if we really want to allow passing null with default typehinted values. Since there is no concept of null references in PHP. Having a value of null to mark not passed is a nice differentiation. So for now the only addition we may probably consider for 5.1 is adding 4: optional typehinted values that default to null and only null. marcus

« previous php.internals (#13556) next »