RE: [PHP-DEV] Type hints with null default values

From: Date: Tue, 19 Oct 2004 02:32:58 +0000
Subject: RE: [PHP-DEV] Type hints with null default values
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-13380@lists.php.net to get a copy of this message
On Mon, 2004-10-18 at 22:09, Robert Silva wrote: > Based on the issues you listed, how about: > > function Method((MyClass) $obj); > function Method([MyClass] $obj); > > Surrounding the class type in () or [] thereby marking it as optional. > Much like you would do when commenting a function to take an optional > parameter. I like this idea and just for the sake of consideration and to elaborate on it: function Method( [MyClass,YourClass,null,bool] $obj ); which would allow all of the above types as values for $obj. Which would allow a great deal of flexibility while retaining a good deal of readability. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.internals (#13380) next »