Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98105 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71475 invoked from network); 1 Feb 2017 06:49:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2017 06:49:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wm0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:36403] helo=mail-wm0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8A/60-51557-6E481985 for ; Wed, 01 Feb 2017 01:49:11 -0500 Received: by mail-wm0-f51.google.com with SMTP id c85so23637114wmi.1 for ; Tue, 31 Jan 2017 22:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vti/h7ID5HXTEdjKblabb6721A3vZYVCjeN4f5334ao=; b=QqVTLjKZ+8hnRE5nC/FXP4k96C36K9HOTNYvpgzGDiYTRYOpc2RybMKLJ4HNYAnZwA fU6TZ10Ufsw1mootFmUBrLRD2TcJaOnH0lpLLf8/6t+cilV7h0gQmYSNyTePM8MIXC4V DjrHS94ny73UK56lKBfl56mKKgnxNbgSGgvvmVbd2XWQkzBjoNK0N7Ukp/DHb+AeVCKg povp4pFlBaNRxYzH9VpOzV1YFIi/G5ehfoYxyNAne90tGEpc5Rq3LqUGys0UpFVHC+kS qClnRv/OuwpZnV2akZj1GZYoA6XKgDaSVPZnSkQmhlVYhfAwVj7VkB/0Ku/2lNsrqTg7 WkfA== 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=vti/h7ID5HXTEdjKblabb6721A3vZYVCjeN4f5334ao=; b=fMYhI05tYJ7qOvCd8Zo+vFx679mEcvdp+FUZzTpMzVgWVTCfWbV+7qAAOlZ3aXwCo1 eH2ZWuvYzIOUNYGdI0ZvNPA0qFSCXIiYl3h89f1j9OZyl2Wvv5XNn6Ae+DG93xFEwlfZ wBv09pr9pF/FJD5mOtH5gmwS3dK5MwKWUndnE8vTqCXr/Z2oIaYOLpHuDrBkPxX1FIWZ TPYF3asOgQ6T9YzNn/NhrTlRgTy1c/sVI8kGCf/2tTP3QgPLxTP9fJ7WHHka6WJAhw0G 0pVwCaPemE8+2LBBoVS/dc9onOPK3h32tbpKD9osKGY3hd6GoeKdSN5Xkwx2MTQ7p9rB fwHw== X-Gm-Message-State: AIkVDXJ+UCsKVbPtMB7jE9a32KG9ptK6PzeqU8t8xJIUDiYe+3cEkH/f5hIsqobTEJza8VtkPqLw6Q8YBw0HEw== X-Received: by 10.28.129.147 with SMTP id c141mr23531986wmd.12.1485931747801; Tue, 31 Jan 2017 22:49:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.34.167 with HTTP; Tue, 31 Jan 2017 22:49:05 -0800 (PST) Received: by 10.194.34.167 with HTTP; Tue, 31 Jan 2017 22:49:05 -0800 (PST) In-Reply-To: References: Date: Wed, 1 Feb 2017 07:49:05 +0100 Message-ID: To: "Christoph M. Becker" Cc: PHP Internals List , Guilherme Blanco , Levi Morrison Content-Type: multipart/alternative; boundary=001a11423eecfd022b05477271af Subject: Re: [PHP-DEV] PHP's support to contravariance and covariance From: ocramius@gmail.com (Marco Pivetta) --001a11423eecfd022b05477271af Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 1 Feb 2017 12:27 a.m., "Christoph M. Becker" wrote: On 31.01.2017 at 21:47, Levi Morrison wrote: >> Is there anything else that I am missing? > > Sadly, yes. Consider the following snippet: > > class A { > function method(): B; > } > > class B extends A { > function method(): C; > } > > class C extends B {} > > When checking that B::method satisfies the requirements of A::method > it must know if C extends B. At the time we check if B::method > satisfies A::method, C will *not* yet be in the symbol table. > > You need to adjust the passes over the code to register symbols and > their declared relationships, and then in a separate pass validate > them. After that if the class isn't found then you trigger an > autoload. > > It's doable, it just hasn't been done. An alternative *might* be forward class declarations: class B extends A; class C extends B; class A { function method(): B; } class B extends A { function method(): C; } class C extends B {} I haven't really thought about the feasibility =E2=80=93 just throwing in a rough idea. That's simply dumping a language problem onto the user though... --001a11423eecfd022b05477271af--