From: wjaspers at nuaire dot com Operating system: CentOS / Windows XP Pro PHP version: 6CVS-2007-04-02 (CVS) PHP Bug Type: Feature/Change Request Bug description: Method Overloading by Method Signature
Description: ------------ Please add the ability to overload methods by their signature. This feature would be the same as Java 5, in that a class could be created with several functions by the same name, but the PHP engine could determine which one to use simply by determining which method signature is being utilized. I would also hope if this is created, that Constructors may also be overloaded by signature. (This would make porting java applications to PHP or vice-versa a cinch). Reproduce code: --------------- As an example, the class below has two constructors with the same name, and three methods with the same name, which would be differentiated simply by the type and number of variables supplied. This would make PHP much more object-oriented, and more robust. <?php class TestMe { var $isValid = false; # intial value public function TestMe() { $this->isValid = false; } public function TestMe(bool $isValid) { $this->isValid = $isValid; } public function validate() { } public function validate(bool $strict) { } public function validate(Validator $validatorObject) { } } ?> -- Edit bug report at http://bugs.php.net/?id=40979&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40979&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40979&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40979&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40979&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40979&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40979&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40979&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40979&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40979&r=support Expected behavior: http://bugs.php.net/fix.php?id=40979&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40979&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40979&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40979&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40979&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40979&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40979&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40979&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40979&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40979&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40979&r=mysqlcfg