Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49456 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75001 invoked from network); 19 Aug 2010 15:10:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2010 15:10:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.185 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 212.25.124.185 il-mr1.zend.com Received: from [212.25.124.185] ([212.25.124.185:39114] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/F7-28424-8594D6C4 for ; Thu, 19 Aug 2010 11:10:18 -0400 Received: from il-gw1.zend.com (unknown [10.1.1.21]) by il-mr1.zend.com (Postfix) with ESMTP id 6725F504F2; Thu, 19 Aug 2010 18:09:34 +0300 (IDT) Received: from LAP-ZEEV.zend.com ([10.1.2.20]) by il-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 19 Aug 2010 18:10:12 +0300 Message-ID: <7.0.1.0.2.20100819180204.18df1cb0@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Thu, 19 Aug 2010 18:10:11 +0300 To: Stas Malyshev Cc: PHP Internals In-Reply-To: <4C6CE273.2070501@sugarcrm.com> References: <4C6CE273.2070501@sugarcrm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-OriginalArrivalTime: 19 Aug 2010 15:10:12.0657 (UTC) FILETIME=[9F1EA210:01CB3FB0] Subject: Re: [PHP-DEV] inheritance check too strict? From: zeev@zend.com (Zeev Suraski) At 10:51 19/08/2010, 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? As others noted I also think that this warning is correct. Code that deals with ObjParent objects is allowed to call to set() with a parameter. It's also supposed to be able to treat ObjChild objects transparently, because they're specialized of ObjParent. If this function signature was allowed - it can end up calling ObjChild::set() with an argument - which ObjChild() doesn't support. The other way around - making ObjChild::set() more support more signatures than the signature it's 'overriding' - makes perfect sense and is allowed. Regarding the other issue that was raised here, I didn't recall we made is_a() checks on class type hints during signature validation, but if we do - it should be done using the same rules - a child class's signature must be at least as lax as it's parent - or more. Zeev