Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105912 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21365 invoked from network); 13 Jun 2019 19:35:29 -0000 Received: from unknown (HELO mail-lj1-f196.google.com) (209.85.208.196) by pb1.pair.com with SMTP; 13 Jun 2019 19:35:29 -0000 Received: by mail-lj1-f196.google.com with SMTP id t28so19203028lje.9 for ; Thu, 13 Jun 2019 09:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NYsnOqBGbYQPi71c964IFp3UmpD2bSnAN2aDvMVmtds=; b=gBm4YkqvoHNfL2tmkJU+fiGv4Md66lJ7Ya/fYN0rV+oUQkRcf82EK1tQHaxMPwawtP Xbpn+9/whtG8ZyMcUCixX1ngS5BLu1gT92pY4As62w9MzIGLfo/bz1f5nfqo1tT0ipcz WKsvWIO8j2izsxlAmOD69vegeBHg/NygrHLK0mrG5vzGOWf1Fo4OGp4jzqIzPvPRYciq oqrVZbnOURh+/AEBqpuxzVNXs8CJTboNDgFqvyQe6NRC9yzcLfAFeZz7GanIgzrdRVTn Vnxus6uKS0SjVwS903MsehDqMb7Hmg8hchKqHcrzXJtqKuUuVTtZa8eQS0SdWqPMi9wD x0XA== 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=NYsnOqBGbYQPi71c964IFp3UmpD2bSnAN2aDvMVmtds=; b=WT4XEpQzaxROadGhUaDykL+4mYuATLdwQtkj61toG8YunESq8XSksp9uWuWmL1WQlE tnDp/ZCYmohTSom5abNTkbqn7UJkIIborOdl+r4y7O/JfsEkoa13ScaU+oapKUTurjjo JoUCuLCrEQAebhIqJJ7K7PtgWj7eSMPEsQYWvY/HbM4Tpyg51Obhd+isyFb9WdeEjCsC 6ltipBcplkA4d/jfMVd3nmC0GTbZR8Djbh2lvy1VlI49LR/nDIAtFYHX/p74kq7ewXO4 cC11QCwNcdCPjPv7lwIfiSVHqRThfH0YDRoySJqJ7ai2v0zHpIgSEyL0W6ySKEbksDbd qo3Q== X-Gm-Message-State: APjAAAWlv08lXMl3uEiDEZ+XbJibE3QX/dBVOJxfGChpW0T43IP6pKdF R/6/jHdlRr0X2MODJFHICqYKrBO4iLDdL4oGM5o= X-Google-Smtp-Source: APXvYqyfOLKTSoQh4kWkzAK59flkooiKmvpvVSoCur4T2cPtdQTZCUgoXs3ZhUafdVuD+9Wk/ZSnNbkUEHVA5vg6biE= X-Received: by 2002:a2e:2c04:: with SMTP id s4mr22909099ljs.61.1560444520120; Thu, 13 Jun 2019 09:48:40 -0700 (PDT) MIME-Version: 1.0 References: <8094526f-88d6-6d46-6f83-4165d65c064a@gmx.de> In-Reply-To: Date: Thu, 13 Jun 2019 18:48:23 +0200 Message-ID: To: Levi Morrison Cc: "Christoph M. Becker" , internals Content-Type: multipart/alternative; boundary="000000000000506b9a058b374de5" Subject: Re: [PHP-DEV] Re: [RFC][Vote] Covariant Returns and Contravariant Parameters From: nikita.ppv@gmail.com (Nikita Popov) --000000000000506b9a058b374de5 Content-Type: text/plain; charset="UTF-8" On Wed, May 8, 2019 at 6:51 PM Levi Morrison wrote: > On Wed, May 8, 2019 at 2:06 AM Nikita Popov wrote: > > > > On Tue, Jan 22, 2019 at 6:59 PM Levi Morrison wrote: > >> > >> On Tue, Jan 15, 2019 at 1:27 PM Christoph M. Becker > wrote: > >> > > >> > On 04.01.2019 at 20:17, Levi Morrison wrote: > >> > > >> > > I intend to close the vote in a day or two, unless I hear of new> > issues from Dmitry or others. > >> > Any news here? > >> > > >> > -- > >> > Christoph M. Becker > >> > >> I sent this a week ago to Christoph only; oops. > >> > >> I have not heard any news. The vote is now closed. The RFC passes 39 > >> in favor to 1 against. > >> > >> Special thanks to Nikita and Dmitry who have helped find issues and > >> review the patch. It will not be merged until the implementation > >> quality is satisfactory. > > > > > > As we're moving steadily towards 7.4 feature freeze, I'd like to discuss > what we want to do with this RFC... The current implementation doesn't work > correctly (I've done some more work in > https://github.com/nikic/php-src/commits/variance-7.4, but it's also > incomplete) and I have some doubts about how we're approaching this in > general. > > > > This RFC really has two parts: > > 1. The actual variance change. This is a very straightforward change and > there are no issues here. > > 2. The ability to check variance across multiple consecutive class > definitions. This allows type declarations to reference classes that are > declared later in the same file (but within one "block" of declarations). > > > > The second part is technically more dicey and somewhat arbitrary when > seen in the wider scope of how class hoisting and early binding work in > PHP: While PHP supports declaring classes "out of order" in some very > simple cases like this... > > > > class B extends A {} > > class A {} > > > > ...it will not work for anything more involved than that, for example > > > > class C extends B {} > > class B extends A {} > > class A {} > > > > will already generate a "class not found" error. > > > > Now the variance RFC tackles one very specific part of this > long-standing issue: The types referenced in parameter and return types may > be declared later in the file (even if used variantly), but all other uses > of the types still need to respect the declaration order. > > > > I think that we should be separating these two issues (variance and > declaration order), and land the simple variance support in 7.4, while > tackling the declaration order problem *in full* separately (in PHP 8, > because I think we may want to make some BC breaking changes, in particular > by making the class hoisting unconditional.) > > > > Thoughts on this approach? > > > > Nikita > > I fully support this approach. I will prepare a patch for simple > variance in PHP 7.4. I intend to leave the existing test cases that > will fail without supporting consecutive declarations, but marked as > expected failures. > > I think in PHP 8 we can already benefit from the [always generate > fatal error for incompatible method signatures RFC][1]. We might also > be able to make some improvements with compile-time errors on invalid > "parent::" usage (previously done for PHP 7.4 but [backed out][2]), > which might make things a bit more straightforward (it might not -- > turns out parent is not exactly what I thought it was). > > [1]: https://wiki.php.net/rfc/lsp_errors > [2]: > https://github.com/php/php-src/commit/deb44d405eb27a6654ad9a57c1e5f641218b22a4 An update on this: The last part of covariance support has landed [1] a few days ago and is part of 7.4 alpha 1. As already described, full variance is only supported in conjunction with autoloading. When working in a single file or with explicit includes, the requirement that classes need to be declared before being referenced (including reference in variant type declarations) remains. This feature turned out to be a *lot* harder than anticipated. My initial assumption that this would mostly "just work" if we ignore the single file case was very wrong... Nikita [1] https://github.com/php/php-src/commit/8f8fcbbd397370b407dc2552c4bd6ee4ccb0e93b --000000000000506b9a058b374de5--