Re: AW: [PHP-DEV] Method overloading by method signature

From: Date: Mon, 15 Oct 2007 08:23:22 +0000
Subject: Re: AW: [PHP-DEV] Method overloading by method signature
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-32771@lists.php.net to get a copy of this message
On 14/10/2007, Hans Moog <hans.moog@mkj-computing.de> wrote: > You are missing something. Using this new feature would be voluntarily (it is optional like > type hints are already). > > If you want to code the old way and you don't want to force coders to use your functions > correctly, you could leave out typehints an check the parameters manually. > > But if you want to write strict API's, that accept only a special type of parameters (and > type hinted parameters were introduced to be able to do this) you would still be able to accept more > than one type of parameters (without this additional feature you are not able to do it right now). > > > You do not use type hints in your functions, thats why you don't understand the need of > overloding methods by parameter siganture. If you would understand the need of type hints for robust > applications you would understand the need of overloading typehinted methods. > > > Btw: You could call foo((integer) $x); to ensure the right method is called. > > Like I already said, this feature is only require for people writing complex web applications, > offering api's to 3rdparty coders that are very strict. If you are coding a project within your > company you can rely on the fact, that programmers should know how to use your methods, but a > 3rdparty coder who extends the functionality of your product doesn't know and there should be > no chance to crash the application. For what it is worth, I would find this functionality EXTREMELY useful. The classes I create ARE used by other developers both within my organisation and outside and as I'm currently porting GUI apps from Delphi to web apps using PHP and missing things like type hinting of scalars AND overloaded function defs is a pain as I now have 1 method with a header which has to parse the parameter types to determine what is required to be called. I think this is a GREAT feature. Even if it was JUST for E_STRICT OOP code. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"

« previous php.internals (#32771) next »