Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99165 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87219 invoked from network); 25 May 2017 09:21:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2017 09:21:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.192.180 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.192.180 mail-pf0-f180.google.com Received: from [209.85.192.180] ([209.85.192.180:34968] helo=mail-pf0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/B3-10292-532A6295 for ; Thu, 25 May 2017 05:21:57 -0400 Received: by mail-pf0-f180.google.com with SMTP id n23so161933474pfb.2 for ; Thu, 25 May 2017 02:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=uBqqzS4W0yCRqvYU1Fs1Da4cIm9JKT783Y02dz4+bAQ=; b=UNj661g/1vlemKnivGSmKu3hZ5B+zfDLG99JzXJNhRYnp5hHpZI+cFk9JAyMdy0NRv 6trJ1M49auBT4x5PpXKFjNf8NYjuq5B/tF6sQqhxBM7QBrC3OxujeHETdEt2jusvekDs 6Ug3PcCP8bRszONusVPVkDIgSGVmKFtJqFCw6TgfZpXtcNe4d+bSAavj+Tsry4bzj7sa VdacfHsTb3CzM2dlMWWG5pbQPeRM4/1UmPwM3zVwBRH+3A9EXFzFtRYCRD2TvepUuVfz B/pfgre3Daf89OW4BPQ0uoDYFn8iLFCLKD0A03fXIOiDIx37JPnZFSEbuo+PsbC5psXK gmZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=uBqqzS4W0yCRqvYU1Fs1Da4cIm9JKT783Y02dz4+bAQ=; b=FDgszAp9JT/Z53hihUu6uQblKfPgonATxHvVVMychxJBJTZTJ8jHq33hL/SZYhFHjT wnI6/hTtjAT+U7MoSwbeDyFhYwYuC6s6kEOkzAgLP1kZESePvCj/KSLxUHxAfK1E4W0Y nW/4DzUktAavnBweYyzQ7WylhMFn//SVL+wTye/zvoWcBZJ9rVlO4CTxEvRE7nqMmIvA 94aDGYWirNH24wMO9Npn73WtLGlOHTKQIvS6IeCohM/jPzjTaKR9DGzqJ3NsNBOcyzhn He+/f1cCutvWZLgiG7pMDqC6kpnDohyMjdP1SFDIPXfnHeA+jvHiM3iVg+x0MtPUR9Zv 9emw== X-Gm-Message-State: AODbwcBhu7du3jSsyXUlK6uDk+8HKeKH8U2DkTETDASG8ApGri9xkyTn naDcAVPzeo8wvOKefg2f/alqfVxSEqLBnWIrNw== X-Received: by 10.84.133.132 with SMTP id f4mr49366850plf.94.1495704114412; Thu, 25 May 2017 02:21:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.131.23 with HTTP; Thu, 25 May 2017 02:21:53 -0700 (PDT) In-Reply-To: References: Date: Thu, 25 May 2017 11:21:53 +0200 Message-ID: To: Niklas Keller Cc: PHP internals Content-Type: multipart/alternative; boundary="94eb2c1869a66dd89c055055c0aa" Subject: Re: [PHP-DEV] Parameter type widening RFC From: rasmus@mindplay.dk (Rasmus Schultz) --94eb2c1869a66dd89c055055c0aa Content-Type: text/plain; charset="UTF-8" > > The feature, as implemented, will allow accidental omission of type-hints, > > will it not? > > Yes, correct. So this breaks the expected behavior of interfaces. This will be harmful to everyone, but especially harmful to new programmers, who may never even learn how to correctly implement an interface, since now they don't have to. Promising to address this in a future version isn't helpful, as that would be a BC break, which rarely anyone condones, even for major releases - changing it now isn't a BC break, so it's easy, but fixing it will be a BC break, which will be very hard to push through. Addressing this by allowing developers to opt-in to proper interface validation in strict mode isn't helpful either, and especially not to new programmers who are likely much farther from learning about strict mode than they are from learning about basic things like properly implementing an interface - and much, much further from learning about parameter type-hint widening. IMO, this is likely to become another one of those historically bad design decisions that were made in spite of everything we know about other programming languages :-( On Tue, May 23, 2017 at 10:46 PM, Niklas Keller wrote: > Hi Rasmus, > > >> This parameter type widening RFC, I didn't know about, but I have a >> remark. >> >> The feature, as implemented, will allow accidental omission of type-hints, >> will it not? >> > > Yes, correct. > > >> Previously, the implements keyword guaranteed a correctly type-hinted >> implementation - it's now possible to (purposefully, obviously, in certain >> rare cases) omit type-hints by accident, making the implements keyword >> much >> less (or not any) of a guarantee that the interface is implemented >> correctly. >> > > The interface will just work correctly, what's the actual problem you're > seeing? > > >> The addition of an explicit "mixed" or "any" pseudo-type would have made >> this possible, without losing the guarantee that the implements keyword >> used to provide - that is, it would have been possible to have this >> feature >> for the few cases where it's useful, without affecting safety in the >> majority of other cases where it's not. >> >> I feel like this feature takes a pretty dangerous shortcut by simply >> removing a constraint check that we used to have - in favor of supporting >> a >> few rare cases, we removed a guarantee that interfaces and the >> implements-keyword has always provided. >> >> Those rare cases could have been supported in a safe manner by introducing >> a "mixed" or "any" type, which would have made the use of this feature >> explicit - which would have removed the risk of accidental omission of >> type-hints in the majority of cases. >> > > Unfortunately, that doesn't work for the second (maybe even primary) use > case of the RFC: Adding types to a class isn't a BC break anymore with the > RFC, as child classes will just widen the type and need explicit checks as > before. Without the RFC or with a version with "mixed" or "any", method > signatures will be incompatible again and thus be a BC break when adding > types to the base class. > > "mixed" has been mentioned in the original discussion, but there was not a > lot of interest and mostly explicit disinterest. > > >> The RFC page doesn't link to any discussion, and the Github thread was >> shut >> down after some negative remarks. >> >> I didn't see a discussion or a vote here on internals - did I miss >> something? Where or how did this get discussed and passed? Are these >> discussions happening somewhere else besides internals now? > > > - Original discussion: https://externals.io/thread/505 > - Vote announcement: https://externals.io/thread/613 > - Vote resumption after internals having issues: https://externals.io/ > thread/619 > > Regards, Niklas > --94eb2c1869a66dd89c055055c0aa--