Re: Return type hints

From: Date: Tue, 08 Apr 2008 10:13:05 +0000
Subject: Re: Return type hints
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-36866@lists.php.net to get a copy of this message
Yes indeed you can implement it using the __call method, but it would be more readable if the language structure itself would support it. I suggested this just because I think that this is the most common way of using overloading, thus this probably would make sense to lot of users out there. But it was only a suggestion among others. /Krister Karlström Arvids Godjuks wrote:
Em, you have __call method in classes - via it you could implement ANY logic for overloading. It's written in manual here: http://www.php.net/manual/en/language.oop5.overloading.php KISS should be followed - no C++ style overloading is needed, PHP is a script language without strict type hinting. 2008/4/8, Krister Karlström <krister.karlstrom@arcada.fi>:
Hi! This is maybe getting a bit out of topic now, but what about function/method overloading using type hinting: function myfunc(string $data) { } function myfunc(int $data) { } function myfunc(myClass $data) { } This currently causes an error in PHP 5.2.5 that function myfunc() can't be redeclared. This would in my opinion be very useful for methods in classes. Greetings, Krister Karlström, Helsinki, Finland Arvids Godjuks wrote: I think type hint's would be good optional functionality. Those who need
will use it, others will not. I'd probably use it in some cases. Especially if named parameters are implemented. Sometimes what I really want is named parameter pass like function myfunc(array $array, string $string = null, int $someint = 0){ } myfunc($myArray, someint = $mySomeInt);


« previous php.internals (#36866) next »