Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101368 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83168 invoked from network); 18 Dec 2017 21:22:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Dec 2017 21:22:20 -0000 Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.49 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.49 mail-lf0-f49.google.com Received: from [209.85.215.49] ([209.85.215.49:42802] helo=mail-lf0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/69-21958-B81383A5 for ; Mon, 18 Dec 2017 16:22:20 -0500 Received: by mail-lf0-f49.google.com with SMTP id e30so2459163lfb.9 for ; Mon, 18 Dec 2017 13:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=h8yLbIsXsRcWY19g67zJzXYEjNt09V+dJLtR6H2hNLo=; b=uEzfcESw+yA934i+hOoOkX1YGe8yJoDiPNY7ysfpjeO2U2x7l8atJagDbb1nK8qhlY gM3K3tmI5xuTJCxN3IMowaoseqDtCzHjMF+5qrfTtypWz2R78Oj2Ytgd82jymzV8Vn9q 7vQSyZFiBCMnuH0csLQrC7M/sMi+kmutxxHlrRRRnumUMFvgxHbgldJ1kE7B3mH382wA kwqlFn96ytScMnj73bnnVrMFt7skQcrQhccHyGfyp489w18MYKJP8pgglL76iiuQ/UoW WXntukegwWPpFtLQcXYoJMytN+qtHIb0VwuL1ENeFAjll+HIaE4xiHANExlttlO0X5Fz WS8A== 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=h8yLbIsXsRcWY19g67zJzXYEjNt09V+dJLtR6H2hNLo=; b=ev5WKESGBXO7bGTi0sMr58i33VqUlu3YC7ZbicFF/f6XRc4i54MQ4lkVXuA+ZybVpe o3w79OdFYo0T7s4R6L8lR2YMYBi8gn+kLnHHfOnRtEaGkmUIqQl3KOuCoeldcnprXLgk i2KtHVG/9wpBIceuXKYlfnlkYotq8K69ldkiVjQZbei9WDhM8sKBwQwUpzNEYMft3/+v wocpIFRi/Y8uHgIxTjVzWpHzAF4wECYXRA32RU85fA4bHStfm40ZipWDC+RQ5+Wro17u lYwjLM+Bd1TW21DoNuXKQN7vHqSSdO4QYLaN0hOfPoqHvIibVfTdnVzF36B+/QqufXK3 h6Cg== X-Gm-Message-State: AKGB3mKOsVaMb0CHHIZk86P/opaoPHj+b1y9VBTzUd0l3c4rQT19sTdo a87hEars+FttSu2pchQI6gCuXIRC X-Google-Smtp-Source: ACJfBosmCyHCo0Xzv9RvbybN2mAizoTQOja34keNzJDcCtTTwS4Y5zEpZVvcEA+4DL3WCBJY7naYeQ== X-Received: by 10.25.28.9 with SMTP id c9mr744905lfc.40.1513632135655; Mon, 18 Dec 2017 13:22:15 -0800 (PST) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com. [209.85.215.53]) by smtp.googlemail.com with ESMTPSA id k188sm2948498lfg.79.2017.12.18.13.22.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 13:22:14 -0800 (PST) Received: by mail-lf0-f53.google.com with SMTP id w196so1416940lff.5 for ; Mon, 18 Dec 2017 13:22:14 -0800 (PST) X-Received: by 10.46.34.196 with SMTP id i187mr827586lji.106.1513632134085; Mon, 18 Dec 2017 13:22:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Mon, 18 Dec 2017 13:21:53 -0800 (PST) In-Reply-To: References: Date: Mon, 18 Dec 2017 22:21:53 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Levi Morrison Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Covariance, again From: andreas@dqxtech.net (Andreas Hennings) > I really think we ought to tackle covariant returns and contravariant parameters My "algorithm" could be extended for contravariance: Whenever a method has a parameter type hint that differs from the parent type hint, autoload the class of the parent type hint. I think I know too little about the internal workings of PHP to understand why your examples would break. I think we should give it a try, and write your examples as unit tests to try to crash it. If we indeed can produce circularity problems, then I might have more ideas. I think the main idea in my algorithm about which classes needs to be autoloaded and which don't is good. Maybe at some point we need to write a class into the table of defined classes, before it is fully verified. At some point, for a different purpose, I thought about "stub" classes, which have all the information from the declaration itself, but not from any parent class. So we could write classes into the stub table and then later write the completed thing into the actual class table/list. But maybe we don't need to go that far. If I were to do this, it would be my first shot on the php engine itself. Not going to happen today, but maybe I will find time for it in a future month or so. I am sure if/when I have done this, I can write more knowledgeable posts here on this mailing list. Of course if someone else wants to step up, go ahead. I think the goal and spec is pretty clear. So once we have a proof-of-concept implementation and show that it can be done and the problems can be solved, it would be straightforward to make an RFC. If we would do the RFC first, people would have to vote on something which is unclear if it can be implemented. On 18 December 2017 at 21:48, Levi Morrison wrote: > On Mon, Dec 18, 2017 at 11:52 AM, Andreas Hennings wrote: >>> I believe your algorithm fails on this simple setup: >> >> Another comment I want to make here: >> The examples you give each have multiple class declarations per file. >> I would personally not care much, if these result in fatal error. >> All of this code used to be illegal until now (because no covariance >> support), so it would not be a BC problem if some of it continues to >> be illegal. > > Just because it isn't a backwards compatibility break doesn't mean > it's a good way forward. Right now people have covariant returns - > they just don't express it in the signature because we don't allow it. > Wouldn't it seem odd that if the bodies of the methods stayed the same > and all they did was update the signature that it somehow breaks their > code? > > I have some ideas about minimizing this impact but I really think we > ought to tackle covariant returns and contravariant parameters at the > same time. Any endeavor to add one should add the other to create a > cohesive design that works in both cases.