Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49450 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6864 invoked from network); 19 Aug 2010 08:31:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2010 08:31:40 -0000 Authentication-Results: pb1.pair.com header.from=dave@dmi.me.uk; sender-id=pass; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=dave@dmi.me.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain dmi.me.uk designates 77.68.52.130 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: dave@dmi.me.uk X-Host-Fingerprint: 77.68.52.130 server77-68-52-130.live-servers.net Received: from [77.68.52.130] ([77.68.52.130:41131] helo=scaramanga.siterage.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 58/F0-04318-BEBEC6C4 for ; Thu, 19 Aug 2010 04:31:39 -0400 Received: from localhost (scaramanga.siterage.net [127.0.0.1]) by scanner.scaramanga.siterage.net (SiteRage Mail Server) with ESMTP id 84CE781CD6; Thu, 19 Aug 2010 09:31:36 +0100 (BST) X-Spam-Flag: NO X-Spam-Score: -2.127 X-Spam-Level: X-Spam-Status: No, score=-2.127 required=5 tests=[ALL_TRUSTED=-1.8, AWL=1.142, BAYES_00=-2.599, DNS_FROM_OPENWHOIS=1.13] autolearn=no Received: from scaramanga.siterage.net ([127.0.0.1]) by localhost (scaramanga.siterage.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mqwM514yAp2N; Thu, 19 Aug 2010 09:31:36 +0100 (BST) Received: from [192.168.1.100] (unknown [78.146.65.175]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by scaramanga.siterage.net (SiteRage Mail Server) with ESMTPSA id A9B9E14523; Thu, 19 Aug 2010 09:31:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dmi.me.uk; s=scara-dkim; t=1282206696; bh=lHRAuNWdqiMsPsEeUafYECvvnIIeM+tgIaJKN52bypw=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=WSeOr11bFyfdoAR30IrORLwtjCh/uql00zBkB7v/Fr2nY/Xvn5F6z0+F7KdYkLHI5 2CGBjKn82R53X7N7Budt4ywAslI20bSM2041qjw/kaCf+t+4VL+Ic20Bryz0PcYFlu sKfKMrM6CH4LwFT+VJaQ3g+r8AFvFewc3whMg3KM= DomainKey-Signature: a=rsa-sha1; s=scara-dk; d=dmi.me.uk; c=simple; q=dns; h=message-id:date:from:user-agent:mime-version:to:cc:subject: references:in-reply-to:x-enigmail-version:content-type:content-transfer-encoding; b=Qe5NRU1qZ5ODBUQ+Zvo9cV6hYCifS4fUor/EHk1iypFDQpHCjO+Up3LkeVSqhRKDK f8IsaEzGzQ1MrzPbOREh4mBdrF1e5geFpt/0Cd5Uh7V64aiTOzyOrKho1mZP3cpW1Af 8ck30lMYQx9h13AHQRF9XSvHA/LHS90dugN6pHQ= Message-ID: <4C6CEBE4.3070306@dmi.me.uk> Date: Thu, 19 Aug 2010 09:31:32 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Stas Malyshev CC: PHP Internals References: <4C6CE273.2070501@sugarcrm.com> <4C6CE604.1010209@dmi.me.uk> <4C6CE793.1020601@sugarcrm.com> In-Reply-To: <4C6CE793.1020601@sugarcrm.com> X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] inheritance check too strict? From: dave@dmi.me.uk (Dave Ingram) On 19/08/10 09:13, Stas Malyshev wrote: > Hi! > >> I was under the impression that, in order for inheritance to provide >> proper polymorphism, overridden methods should share the parent's method >> signature, although they can have additional optional arguments. > > Your impression is wrong. Overriden method should have _compatible_ > signature - i.e. accept any argument set that parent object accepted. > Nothing requires it to have the same signature. Maybe I didn't express myself clearly: I meant that the arguments in the child's signature must be a superset of the arguments in the parent signature, in the same order. Any required arguments in the parent may be made optional in the child, but not vice versa. The child is free to accept additional optional arguments, but not exclude any from the parent. This provides consistency in the same way that (although I haven't tested in PHP) you should be able to increase the visibility of an overridden method in a subclass (e.g. protected -> public) but not decrease it (e.g. protected -> private). >> Otherwise, if you're passed an ObjChild when you are treating it as an >> ObjParent, you could get unexpected behaviour if it ignores $param2 when >> you decide to specify it. PHP doesn't complain about a programmer > > Unexpected by whom? Writer of ObjChild->set() knew how to implement it > without that parameter, so why behavior would be unexpected? I'm assuming that the parameter would cause variations in behaviour (which is generally the reason for having parameters), so by definition ignoring it would cause different behaviour. I presume that this would be unexpected. >> passing too many arguments to the function as far as I recall, so this >> sort of bug can be easy to overlook. > > How this is a "bug"? Arguments being silently ignored sounds like a potential bug to me. I know it's something I've seen in code I've maintained. I am prepared to be shown to be wrong on any of these points, though this is the way I understand things to work from both common sense and half-remembered OO principles in CompSci. D