Re: Return type hints

From: Date: Tue, 08 Apr 2008 10:05:23 +0000
Subject: Re: Return type hints
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-36864@lists.php.net to get a copy of this message
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); > > > > > -- > * Ing. Krister Karlström, Zend Certified Engineer * > * Systemutvecklare, IT-Centralen * > * Arcada - Nylands Svenska Yrkeshögskola * > * Jan-Magnus Janssons plats 1, 00550 Helsingfors, Finland * > * Tel: +358(20)7699699 GSM: +358(50)5328390 * > * E-mail: krister.karlstrom@arcada.fi * > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#36864) next »