ID: 40979 User updated by: wjaspers at nuaire dot com Reported By: wjaspers at nuaire dot com Status: Open Bug Type: Feature/Change Request Operating System: CentOS / Windows XP Pro PHP Version: 6CVS-2007-04-02 (CVS) New Comment:
I would also like to add: Could future versions of PHP PLEASE, PLEASE, PLEASE recognize basic data types such as 'char','int',and 'string' as they are passed through the method signature. That way, if the wrong data type is submitted, a ClassCastException or other situation can occur to indicate either to the programmer or the end-user that the data supplied is not correct? An example as such: <?php class Me { [...] function setMyName(String $myName) { $this->name = $myName; } [...] } ?> Previous Comments: ------------------------------------------------------------------------ [2007-04-02 17:30:02] wjaspers at nuaire dot com 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 this bug report at http://bugs.php.net/?id=40979&edit=1