Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81835 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68312 invoked from network); 4 Feb 2015 18:54:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 18:54:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:55446] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4A/05-40930-2EA62D45 for ; Wed, 04 Feb 2015 13:54:26 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 4453CB0008E; Wed, 4 Feb 2015 13:54:23 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id nzXJYdMT6l6b; Wed, 4 Feb 2015 13:54:23 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 8B1A3B0007B; Wed, 4 Feb 2015 13:54:22 -0500 (EST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: Date: Wed, 4 Feb 2015 18:54:20 +0000 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <5464CFC6-0E2B-4665-8BF3-D0F0118CF6F6@ajf.me> References: To: Nikita Popov X-Mailer: Apple Mail (2.2070.6) Subject: Re: [PHP-DEV] Allow dropping typehints during inheritance From: ajf@ajf.me (Andrea Faulds) Hi Nikita, > On 4 Feb 2015, at 18:49, Nikita Popov wrote: >=20 > Currently we do not allow [1] removing a typehint during inheritance. = For > example the following code is not valid: >=20 > interface A { > public function method(Typehint $param); > } > class B implements A { > public function method($param); > } > // Fatal error: Declaration of B::method() must be compatible with > A::method(Typehint $param) >=20 > The above code does *not* constitute an LSP violation, because = B::method() > accepts more inputs than A::method(). However we still forbid it. >=20 > This is an issue, because it makes it impossible to add typehints to > parameters at a later point in time. I've seen this issue come up both = in > userland code, as well as in a recent DateTime change, see > = https://github.com/php/php-src/commit/8e19705a93d785cd1ff8ba3a69699b00169f= ea47 > . >=20 > Instead of reverting the DateTime BC break, I'm wondering if it = wouldn't be > better to fix the root cause by making the inheritance check less = strict > and allow removing typehints? Sounds sensible to me. Of course, the reverse is true for return types, which should be either = covariant or invariant. :) -- Andrea Faulds http://ajf.me/