Re: Return type hints

From: Date: Tue, 08 Apr 2008 09:17:36 +0000
Subject: Re: Return type hints
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-36863@lists.php.net to get a copy of this message
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 *

« previous php.internals (#36863) next »