Hi!

On 9/19/11 1:40 AM, Gustavo Lopes wrote:
If the subclass method specifies less parameters, it is very likely a
mistake. It's not usual (certainly it's not more frequent than a mistake

Why would it always be? I had code where overriding class had methods that need less arguments and substituted defaults or overrode values for some parameters. I never had a code (which survived longer than 2 minutes without editing) where one just forgot to specify arguments to a method that's using them - any half-decent IDE would discover that in seconds and alert you. I don;t think it's a place of the engine to decide perfectly valid language use is a "mistake" and throw errors just because somebody dislikes it.

being the case) for arguments to be simply intentionally ignored. In fact,
I don't know of any popular language that implements this type of
contravariance. Plus, consider the case in which the superclass takes an

Most languages that check signatures are compiled languages, in which variable arguments are implemented differently than in PHP. For example, Python doesn't have this kind of signature enforcement at all (so you could claim it allows this type of contravariance, too) - and yet you don't think this is the reason we have to abandon it, right?

argument by reference:

function increment(&$foo) { $foo = $foo + 1; }

It is obvious that in this case a subclass override that takes no
arguments cannot possibly satisfy the contract of the original method.

In this particular case it would not be right, but it's not the reason to prohibit it in many other cases where it is. The fact that you can write wrong code if you try really hard shouldn't be a reason to prevent perfectly correct code from working.

* Allow arguments with a supertype. For instance, this should give no
warning:
* Allow extra parameters with a default value (implemented):

* Allow ignoring parameters or introducing defaults
* Remove fatal errors. Fatal errors should be when the engine can not continue, not when the code is perfectly workable but we frown upon such use of the language. This is especially true in non-compiled language where all fatal errors break application in runtime.

--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to