Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49448 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2274 invoked from network); 19 Aug 2010 08:06:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2010 08:06:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=dave@dmi.me.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dave@dmi.me.uk; sender-id=pass; domainkeys=good 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:51354] helo=scaramanga.siterage.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0D/00-04318-E06EC6C4 for ; Thu, 19 Aug 2010 04:06:41 -0400 Received: from localhost (scaramanga.siterage.net [127.0.0.1]) by scanner.scaramanga.siterage.net (SiteRage Mail Server) with ESMTP id BCE1AE4AE7; Thu, 19 Aug 2010 09:06:35 +0100 (BST) X-Spam-Flag: NO X-Spam-Score: -2.032 X-Spam-Level: X-Spam-Status: No, score=-2.032 required=5 tests=[ALL_TRUSTED=-1.8, AWL=1.237, 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 CujXiIWOuAXj; Thu, 19 Aug 2010 09:06:34 +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 7354C8198F; Thu, 19 Aug 2010 09:06:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dmi.me.uk; s=scara-dkim; t=1282205194; bh=k19hhyO2J6TELsNyya4Cp/kxt7XPHojNHpWhy7WBKkQ=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=LflnVjFkXuC4fTpRxh763/6d03J5ffGWUs08e3ASE1SkzJo2pDgLNsk04WznNseQt giG3hX1vbYrMi53GoxphGU+6WH3JZKvh5fOUzR39e8SHhvI6cQbvpFqn59UKd8woLV pVKoE+KNB/tAtNZZjkZmZ8GvDFUEK5Zimk/GSSds= 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=JJLTZb1F8ZmLysJWvEVkNUYmzd5iRcYh/khZHq6UB5p03pJ7mJerWs8ZaQj2MnSar IbINIYGd0b/BjXoMl/XeJ84Pacx3O5AYdydIX1C0L8B2eKt9Gm2rlcxQ/oqkpFXJ6Fh mWzp/PQ1q0NDqsup8Ca3vJ8FUhZjlWYP6wDsN/U= Message-ID: <4C6CE604.1010209@dmi.me.uk> Date: Thu, 19 Aug 2010 09:06:28 +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> In-Reply-To: <4C6CE273.2070501@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 08:51, Stas Malyshev wrote: > Hi! > > I recently noticed this code: > > error_reporting(E_ALL | E_STRICT); > > class ObjParent { > public function set($param2 = ''){ } > } > > class ObjChild extends ObjParent { > public function set(){ } > } > > produces a E_STRICT warning. I don't really see a point in it - > there's no problem whatsoever with child function ignoring some > arguments from parent call. Anybody could explain why this check is > there? 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. 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 passing too many arguments to the function as far as I recall, so this sort of bug can be easy to overlook. I hope that makes sense :-/ Dave