#31785 [NEW]: Add Mulitple Type hinting
| From: | CaptainN at adcstudio dot com | Date: | Mon, 31 Jan 2005 22:18:43 +0000 |
| Subject: | #31785 [NEW]: Add Mulitple Type hinting | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-73159@lists.php.net to get a copy of this message | ||
From: CaptainN at adcstudio dot com
Operating system: All of them
PHP version: Irrelevant
PHP Bug Type: Feature/Change Request
Bug description: Add Mulitple Type hinting
Description:
------------
Since php is a dynamicly typed language, it would be great if we could
supply multiple type hints for a function or method.
This would kind of be like function argument type overloading, where the
overload is handled within the same function.
It could look something like the example below. In this example, both
Class1 and Class2 could have __toString methods defined, so that it
doesn't matter what the rest of the class looks like, since this function
is just going to convert them to strings, then output that value anyway:
Reproduce code:
---------------
function testFunction(ClassName1|ClassName2 $Obj) {
echo 'Class Info: ' . $Obj;
}
/*
Another example (combined with support for built in types in type
hinting):
*/
function SetupDatabase(DatabaseConfig|boolean $config=false) {
if ($config) {
$this->config = $config;
}
$this->Connect();
}
Expected result:
----------------
If this is not the proper place to post these kinds of requests/feature
explorations, please let me know.
Thanks.
--
Edit bug report at http://bugs.php.net/?id=31785&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31785&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31785&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31785&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31785&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31785&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31785&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31785&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31785&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31785&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31785&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31785&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31785&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31785&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31785&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31785&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31785&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31785&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31785&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31785&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31785&r=mysqlcfg