Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101363 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71325 invoked from network); 18 Dec 2017 18:53:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Dec 2017 18:53:17 -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:45568] helo=mail-lf0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/87-21958-C9E083A5 for ; Mon, 18 Dec 2017 13:53:17 -0500 Received: by mail-lf0-f49.google.com with SMTP id f13so18899202lff.12 for ; Mon, 18 Dec 2017 10:53:16 -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=vnIqGF331DoQbzt4p0lueR+e3yzhVglrNKzT3QbMjuo=; b=NjKyj0a92UWQH6QzU6S1+2vkny4g8wxu5Iqsgahly41mkh5pI2MKLZVZXGPM6gMSF9 j7eoSLe3WDv5Z4NqcRGMP2duRouSdDLs0LhuV1sZjL0N9uN1pHhSpB9QdNi9sES17ywf p1lXcqowE+OxUFy5FSKzNFr2rd+8LG5H0PZ00pkvxOHPfgm01dgYhwERChEAVjXLvxAa nmRGRq1BflpS3/RTd6J6SvvVYPSnbiTvMLU/V+f2aHFnBwb9nK7Z2JdYM0ls4fUCFJuO neY+gMc9YAErCrSiD8+zGHLt5YpLtS9p+F8vz3MaGUnx8eJkL8czSynaYWhBE3CDdqR6 cx7Q== 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=vnIqGF331DoQbzt4p0lueR+e3yzhVglrNKzT3QbMjuo=; b=NEtYpwjuq/+p8qYcIQMuf6yzTUGowGk61VeyPj5D9QJyvjQZ+Fkw0pYkilZXw7kpMD 7VX7XuTiQE1DorMNKs+Asx795L0jEnp5vxv8DZbs3dxSlMa2NPNR+07j1eh/mrq5VRFl IcpcerslxOrqIJ0qbztrCf5Aox3UjyjhAy0VAcnuVN/OqDRisPJq+9cD2giOUe6vIdS9 977n4JA3PpGJpcP+ydkNh/vHWPtRs9pcTiI4602Okl8sSVI2WUvMLWnjFOzdz/KrHv69 g/8SxYUH8AxVtw2+3uPVd5X+SbyqMk1/8mcogauxZEQFt0ndOMI88g+Vl6+8TtuQ2JRT i60w== X-Gm-Message-State: AKGB3mJDFOVW76HV6rra2fQYU4e6EB7lG3v6EGNIGUF2qqBrP5yehhNK 95aqUOlKxZkafC4BXRyhU9QV3sQr X-Google-Smtp-Source: ACJfBosqzEuAINjx5CPa9E4CpPYYTUrHnQWb8c/2di+pbFLpoy7WS9GRYSzGMVpMT6awwbNnGC5ZTg== X-Received: by 10.25.198.147 with SMTP id w141mr541295lff.84.1513623193152; Mon, 18 Dec 2017 10:53:13 -0800 (PST) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com. [209.85.215.43]) by smtp.googlemail.com with ESMTPSA id z81sm2886773lff.80.2017.12.18.10.53.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 10:53:12 -0800 (PST) Received: by mail-lf0-f43.google.com with SMTP id g80so14472121lfg.0 for ; Mon, 18 Dec 2017 10:53:11 -0800 (PST) X-Received: by 10.46.99.84 with SMTP id x81mr622003ljb.55.1513623191340; Mon, 18 Dec 2017 10:53:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Mon, 18 Dec 2017 10:52:50 -0800 (PST) In-Reply-To: References: Date: Mon, 18 Dec 2017 19:52:50 +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 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. This being said: I think we can probably construct examples that have one-class-per-file, but that still have a circularity problem due to covariance. Or possibly even with class_exists()? I am going to play around a bit. > > > interface A { > function foo(): X; > } > > interface B extends A { > function foo(): Y; > } > > interface X { > function bar(): A; > } > > interface Y extends X { > function bar(): B; > } > > ?> > > If I correctly typed this from memory there is no way to order this > such that all units are defined ahead of time as needed for verifying > correctness. This means we trigger the autoloader even though the type > is defined in the same file. Even if we do some more complicated > compile-time passes we'd fail on things like this: > > > interface A { > function foo(): X; > } > > interface B extends A { > function foo(): Y; > } > > if (getenv("ENABLE_X")) { > interface X { > function bar(): A; > } > } > ?> > > interface Y extends X { > function bar(): B; > } > > ?> > > This case shows that care needs to be taken to get the order down > correctly even if we autoload: > > interface A { > function foo(): X; > } > > interface B extends A { > function foo(): Y; > } > ?> > interface X { > function bar(): A; > } > ?> > > interface Y extends X { > function bar(): C; > } > // At this point the engine will need to verify A and C but we may not > have finished verifying A and B yet > ?> > > All-in-all I don't think we can resolve every case cleanly because we > do not have purely ahead-of-time compilation for all units involved. I > think every method of implementing this feature has drawbacks and we > need to thoughtfully evaluate them.