Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99254 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1671 invoked from network); 30 May 2017 06:24:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 May 2017 06:24:58 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.192.178 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.192.178 mail-pf0-f178.google.com Received: from [209.85.192.178] ([209.85.192.178:36703] helo=mail-pf0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/CC-34073-9301D295 for ; Tue, 30 May 2017 02:24:58 -0400 Received: by mail-pf0-f178.google.com with SMTP id m17so62800755pfg.3 for ; Mon, 29 May 2017 23:24: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=Pk8GTIa3iQjw9cQ30JbAAnUhHSLccOdQSTSeKOan9+4=; b=NY2zaewwLjXiEvL3blxpGNWoSD31KWEDxgPu95cYCLO3cVki5toNwWHwZuJyMh4LSe wXuA5efrZXnNPVlCNqs4D+r+pgk70GKz/sQeLLkDCLrBmLH1ds15JM4AxnolBpgUL3Dj VT3j5oCEIEVDHD0QPHMbmJcbrpo323vJVdl1CYIJz5a3jwkpixlXhyI/l4+eS+0ZSXi3 8qIpVqz0kB22m606WqHT3yDVygwScezMUwrohdsNCSOOmk6CZEh73tRgXF8Pyh6Xv8Ac pgPCkS6H61hOOReZVg4jJpf4szhc9sVeqQjCLTOdZIzeYnwiClZLb/NVj1nY5LqCUwW8 fBpQ== 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=Pk8GTIa3iQjw9cQ30JbAAnUhHSLccOdQSTSeKOan9+4=; b=l4Tfeo+vf3hprihvsiENWSrNuqR4XUf69VXUrO2ATW/NlYybHTEte9Cwq3GRVqk91e CMgfnysiMUSqG7//+8Tk1n+/lcEBoruGb3gG0lEBiUhZUt55iz/OAABmtcnlL4LAIfsL Xm6C59c28uHogCrDtVmddqZytZ6X6rEQK/4rJU9Xz7fXcD4Yza5H4wiHaPVmVtYszdI6 YUS5jiJaoVAFN1dxkf9gHbw1azLSbuyo7b9ACy7Bcqochzp2C2RbunFKvyQYx8Y5ro1r 10aW1TBntUe39ifBwtZvj3rM4gZVgSr/wht7adT2q10KtJQqwJYSKYD9fIuWbbZSXDa1 tpDQ== X-Gm-Message-State: AODbwcCRNsuSkc1kuG1ybym/ay5hs/MrumnLfEgbQ1hEn1WnRBeOMVET u1S0alonsTD0OEdzaF/CzWTMl2nYaQd2YCU= X-Received: by 10.98.211.87 with SMTP id q84mr21996808pfg.126.1496125494776; Mon, 29 May 2017 23:24:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.131.23 with HTTP; Mon, 29 May 2017 23:24:53 -0700 (PDT) Received: by 10.100.131.23 with HTTP; Mon, 29 May 2017 23:24:53 -0700 (PDT) In-Reply-To: References: Date: Tue, 30 May 2017 08:24:53 +0200 Message-ID: To: Dan Ackroyd Cc: PHP internals , Niklas Keller Content-Type: multipart/alternative; boundary="f403045cc8a2a7e8cd0550b7dc9d" Subject: Re: [PHP-DEV] Parameter type widening RFC From: rasmus@mindplay.dk (Rasmus Schultz) --f403045cc8a2a7e8cd0550b7dc9d Content-Type: text/plain; charset="UTF-8" > The type widening RFC makes it easier to move to parameter types for existing libraries. I'm curious to see how you'll set the version constraint in your composer.json file. After adding a scalar type-hint to an interface, which is a breaking change in 7.0 and 7.1, but a non-breaking change in 7.2, is the new version of your package a major or minor release? If you release it as minor, you'll need a PHP version constraint like "^5.5, ^7.2", but excluding 7.0-7.1 In that way is itself a breaking change, so likely your only practical move is to release (and commit to maintain!) both major and minor versions, which doesn't sound easy at all. On May 29, 2017 00:53, "Dan Ackroyd" wrote: > On 28 May 2017 at 14:25, Rasmus Schultz wrote: > > > > To me, that's a setback that leads to harder-to-debug errors, and > increases > > learning-curve. > > Everything is a trade-off. The type widening RFC makes it easier to > move to parameter types for existing libraries. > > While I can see what you mean about how it could lead to more > accidental errors, for me at least, it would be actually quite hard to > not notice those errors in the code. > > First, when people are programming against the interface rather than > the implementation, that type of mistake is much easier to spot. > > function foo(Repository $repo) { > $repo->save(new stdClass()); > // The above line is marked as an error in any decent IDE > // or code analysis tool. > } > > Second, accidentally dropping the type from the parameter is also an > easy mistake to spot. > > class UserRepository implements Repository { > public function save($item) { > // When inside this function the programmer has no idea > // what type item is. Any call to a method or property will > // be marked as a potential error either by an IDE, static > // analysis tool, or just the programmer realising > // "that parameter has no type". > } > } > > So, to me (and possibly others who voted for the RFC) the ability to > add types to interfaces without breaking implementing library is a > good trade-off. > > And yes, the type system in PHP could definitely be improved. Perhaps > you could propose an RFC? I suspect it might need to target PHP 8. I'm > personally hoping that some form of the union type RFC could return, > though possibly in a more general form. > > cheers > Dan > Ack > --f403045cc8a2a7e8cd0550b7dc9d--