|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2005-01-31 23:55 UTC] helly@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 14:00:01 2025 UTC | 
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.