Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105180 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76372 invoked from network); 9 Apr 2019 18:38:47 -0000 Received: from unknown (HELO mail-lf1-f68.google.com) (209.85.167.68) by pb1.pair.com with SMTP; 9 Apr 2019 18:38:47 -0000 Received: by mail-lf1-f68.google.com with SMTP id 10so12663921lfr.8 for ; Tue, 09 Apr 2019 08:35:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dwDOd2jraFyWtSZFhFv4UQt1XpF29NcHoqeTPfoMDyI=; b=Alx5ltN07pnVFRKXrvaBQx0lgGBLXc6w88YO/1He4BI8W7GoghTaIDA8MZdm90cqmv sMerZ6kSePLzRpTJvdQKNY2vN11dA2QStGbk5+kkMK5XwJhudCprJm3m2XQ77G/lQuFl c/WV+gXPp1nz1DpSNPO2capQ+8t2f9qs8qzg9o2tHT4Y/J7W8nw/SiyCQlvTKIPR98TC UYAA+StjVzL5Ov3ZxhAv2wHZ9Rl0brvdejeC9WMwmgG99A1qTKBF+1tsTkaNUdp5/rNx Qf1yqbBU0EN1oT8WzPOqd99/TQGC8mWLWc1JpbWY7L6CgvOSE9kSfQ6Xmsk0Q3US1loB M6aA== X-Gm-Message-State: APjAAAWijAw2txs2bldxdX7T1F0ub+VQFBrR6Q9q10/VYcs6pniIeaM+ RkUYJQj51EtSGV0ZBzEKxzvHpYdz0qf28M9a3ec= X-Google-Smtp-Source: APXvYqzdjOwQLp7MmRVYjZ24YJfyzUJ3aVHrjrQVuwfv7y74V/vtlxDyB2yDItw38Xo1IlFBKPXsLDbPMlpZ+7IdEGc= X-Received: by 2002:a19:6a02:: with SMTP id u2mr19603178lfu.20.1554824141640; Tue, 09 Apr 2019 08:35:41 -0700 (PDT) MIME-Version: 1.0 References: <3BCEA463-BD9B-468B-AF26-E0AD75C5F559@gmail.com> <16a029d2430.27c1.08be835b7d1a2c2edb4c4286afe1a236@gmail.com> In-Reply-To: <16a029d2430.27c1.08be835b7d1a2c2edb4c4286afe1a236@gmail.com> Date: Tue, 9 Apr 2019 09:35:24 -0600 Message-ID: To: Gabriel O Cc: Dan Ackroyd , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Always generate fatal error for incompatible method signatures From: levim@php.net (Levi Morrison) On Tue, Apr 9, 2019 at 9:00 AM Gabriel O wrote: > > I believe rfc deals with reverse situation > > On 9 April 2019 4:47:50 PM Dan Ackroyd wrote: > > > On Tue, 9 Apr 2019 at 11:58, Gabriel O wrote: > > > >> And this RFC conveniently shows only big LSP violation examples like array > >> -> int, but not widely used narrowing like mixed/object -> specific instance. > > > > > > Type narrowing or contravariant parameters is properly supported for > > PHP 7.4: > > https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters > > , which is why this RFC doesn't need to cover them. > > > > cheers > > Dan > > Ack If you want the reverse to be true, then your code has bugs waiting to show themselves. The earlier we can catch these bugs, the better. One thing to note is that return type information does permit optimizations in some cases. For instance, I believe if a private method has a return type constraint of int, then the optimizer can rule out certain edge cases, and in some cases use type specialized handlers. We can do these sorts of optimizations in more places if the LSP issues are always errors, instead of warnings. So for both correctness and performance, I support this change.