Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81909 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59876 invoked from network); 5 Feb 2015 12:16:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 12:16:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:59938] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/56-27691-52F53D45 for ; Thu, 05 Feb 2015 07:16:38 -0500 Received: (qmail 21854 invoked from network); 5 Feb 2015 13:16:33 +0100 Received: from cm135-167.liwest.at (HELO RoLaptop) (81.10.135.167) by ns73.kreativmedia.ch with ESMTPSA (AES256-SHA encrypted, authenticated); 5 Feb 2015 13:16:30 +0100 To: "'Julien Pauli'" , "'Andrea Faulds'" Cc: "'Hannes Magnusson'" , "'Nikita Popov'" , "'PHP internals'" References: <4A36329B-F17B-4665-A84E-D8CF01F5B29A@ajf.me> In-Reply-To: Date: Thu, 5 Feb 2015 13:16:29 +0100 Message-ID: <007e01d0413d$92e70ad0$b8b52070$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQGT0XnrbIGLsDRs7AVh3vczbttSBwJ9YssaAiel1UIBiO4vcJ0paAMg Content-Language: de-ch Subject: AW: [PHP-DEV] Allow dropping typehints during inheritance From: php@tutteli.ch ("Robert Stoll") > -----Urspr=C3=BCngliche Nachricht----- > Von: julienpauli@gmail.com [mailto:julienpauli@gmail.com] Im Auftrag = von Julien Pauli > Gesendet: Donnerstag, 5. Februar 2015 13:10 > An: Andrea Faulds > Cc: Hannes Magnusson; Nikita Popov; PHP internals > Betreff: Re: [PHP-DEV] Allow dropping typehints during inheritance >=20 > On Thu, Feb 5, 2015 at 2:08 AM, Andrea Faulds wrote: >=20 > > Hi Hannes, > > > > > On 4 Feb 2015, at 23:58, Hannes Magnusson > > > > > wrote: > > > > > > So what it supports "more inputs"? > > > It does constitute an LSP violation. "more inputs" is not what the > > > guarantee is at all, if that is what you want you'd typehint on a > > > interface. > > > > > > > > > It is a LSP failure to allow a string, or any other scalar value, > > > when the parent requires a specific type/object. > > > > > > It sucks that we fail our arginfo very frequently, but this is the > > > way > > it is :] > > > > An interface requires only a minimum standard for accepted input. If = a > > class implementing that interface allows a wider range of values, = but > > still allows at least what the interface requires it to, it is not = an > > LSP violation. Scalars are not special. > > >=20 > If we allow larger type, why doesn't such code work ? >=20 > interface A { } > interface B extends A { } >=20 > class C { > public function foo(A $a) { } > } >=20 > class D extends C { > public function foo(B $a) { } // E_STRICT } >=20 > This is wrong IMO. >=20 >=20 > Julien.P Because this would be covariance and violates LSP. Considering the = following: function foo(C $c){ $c->foo(new A); } if you substitute C with D then suddenly the code would not work = anymore. Cheers, Robert