Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99220 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80954 invoked from network); 28 May 2017 22:53:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 May 2017 22:53:35 -0000 Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 74.125.83.43 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 74.125.83.43 mail-pg0-f43.google.com Received: from [74.125.83.43] ([74.125.83.43:35568] helo=mail-pg0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/31-03918-DE45B295 for ; Sun, 28 May 2017 18:53:34 -0400 Received: by mail-pg0-f43.google.com with SMTP id 8so14639313pgc.2 for ; Sun, 28 May 2017 15:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SRxk58Bhg0Q1K67Unxe6ex7FHFGe3Tt4sat88FJnsyA=; b=2HxXLux6s83t0fgWr5GdFEYJBd1zUCrDK7x/WO9OIz3CNCYiP+j9DT7Au/+Vh2cDj9 8WYL5+Kft+npnqdT/3V+uavGqk2MC+e3RHh4qIn678rghjwzGnILg7ZnvwVWok1NcbJE muX7wrCTflqqM3myxEBkJpwqd+/m2lgzUGcgUzAOU0xW5kMTnu7reCyX7NTz5by4bO1M r0d+ZxeRNvOZSWcL2Q9GTnXt9ehhk2rKNZEMcaTRK0ArKsm7xBIt4M7RI1Fu81hWMipH 9ck4CfIrHfoUgTYGaH074eGyjOYz1vIND0EoIAycrwAYu10sGDYqxPS3PJStRUvnXwP4 H11A== 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=SRxk58Bhg0Q1K67Unxe6ex7FHFGe3Tt4sat88FJnsyA=; b=Wi94tDrZGAtJA7SP6OOkPGUFuV/abUUSkbihfnQtGw/R7xrFvxUAtPOxPslQ8uq4bb sjh3iG1anOui5JcprECOzMn0VQ5Nbk7a7Sxb9NuZHnLiaMGiPDm4Oxu2vjYxv74YfWGo 1vW8ZAQgGgys4R4xU6jxFQSAlY2Cbb57NxJEjVAZ3lFnoZqe5eazPhHqgNrudzUOGGNx hEo65JckNLxqBncVXC07reyNtn97Zl/If/35b41NtqULA7AHfAtwAm9S7VkRoeTFev3p AKyYSI/GBAQNKLlQOj4wP7dDZdv+CsWWC779LU7oHhBCKtN/geDs6GMwT35lmz04v3+v G0FQ== X-Gm-Message-State: AODbwcAt4E0yNnxxfjybTjIjnIO+IzRcbcHG2xOS4hL3PBxpcbJiLlBF tYwNK/HnXThW9PiuKxOxC6P/ul95+Hpp X-Received: by 10.98.219.130 with SMTP id f124mr14351300pfg.171.1496012011123; Sun, 28 May 2017 15:53:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.151.163 with HTTP; Sun, 28 May 2017 15:53:30 -0700 (PDT) X-Originating-IP: [77.99.17.151] In-Reply-To: References: Date: Sun, 28 May 2017 23:53:30 +0100 Message-ID: To: Rasmus Schultz Cc: Niklas Keller , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Parameter type widening RFC From: danack@basereality.com (Dan Ackroyd) 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