Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26213 invoked from network); 26 May 2017 16:16:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2017 16:16:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=lists@rhsoft.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=lists@rhsoft.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain rhsoft.net designates 91.118.73.15 as permitted sender) X-PHP-List-Original-Sender: lists@rhsoft.net X-Host-Fingerprint: 91.118.73.15 mail.thelounge.net Received: from [91.118.73.15] ([91.118.73.15:53509] helo=mail.thelounge.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2A/F6-10292-1F458295 for ; Fri, 26 May 2017 12:16:50 -0400 Received: from srv-rhsoft.rhsoft.net (Authenticated sender: h.reindl@thelounge.net) by mail.thelounge.net (THELOUNGE MTA) with ESMTPSA id 3wZB8t0zqhzXMl for ; Fri, 26 May 2017 18:16:46 +0200 (CEST) To: "internals@lists.php.net" References: <269187f4-5924-a7cc-9163-40134546451f@fleshgrinder.com> <2dca6983-bbde-6042-6608-a593df2e85ed@gmx.de> <35177214-db24-5bc8-2020-37b2951259a2@rhsoft.net> <13ad1065-ef32-067b-5e53-19da3eaa9f76@rhsoft.net> Message-ID: <76030873-a2de-8b3b-cae3-7243ef3a2596@rhsoft.net> Date: Fri, 26 May 2017 18:16:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-CH Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Parameter type widening RFC From: lists@rhsoft.net ("lists@rhsoft.net") Am 26.05.2017 um 18:10 schrieb Ryan Pallas: > > > On Fri, May 26, 2017 at 9:01 AM, lists@rhsoft.net > > > wrote: > > > > Am 26.05.2017 um 16:26 schrieb Dan Ackroyd: > > On 26 May 2017 at 13:23, lists@rhsoft.net > > wrote: > > does that also fix the issue > https://bugs.php.net/bug.php?id=74394 > > > > Dear Anonymous, > > That "issue" is actually 3 issues. > > case 1 > > class A { > public function test($a) {} > } > class B extends A { > public function test(string $a) { } > } > > This breaks LSP - because B::test doesn't accept all the things that > A::test can accept and so is unlikely to ever be supported. > > > and how is that a problem? > > A accepts anything > B limits it's inut to a *subset* of "anything" > > Because, if I have a function foo(A $a) { $a->test(new Bar()) } that I > cannot pass B into this function, even though it is a subclass of A. You > should be able to pass any subclass where its parent is expected, > allowing parameter narrowing (covariance) would break this. well, that case is at least a warning but add a return-type to the parent is a *fatal error* until you update the child class and that makes introducing return-types harder than it should be something like "covariance class {}" would be xtremely helpful for all that cases where you don't pass objects all day around but have them as a *library* in a singletone - in such cases there is no technical difference when you add a retrun-type to the parent class then before except that what was over years just a "@return integer" is now instead of a comment a language construct