Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98297 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76947 invoked from network); 15 Feb 2017 07:52:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Feb 2017 07:52:43 -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 209.85.216.182 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.216.182 mail-qt0-f182.google.com Received: from [209.85.216.182] ([209.85.216.182:34441] helo=mail-qt0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/38-23443-9C804A85 for ; Wed, 15 Feb 2017 02:52:41 -0500 Received: by mail-qt0-f182.google.com with SMTP id w20so130266937qtb.1 for ; Tue, 14 Feb 2017 23:52:41 -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=xQNCsAi0lBnoHh0vSAc+9LTFN8bCjRBhRubKfMpS//Q=; b=FrI0fJ5L4niPg/jtv7SMAlU7TXwrdxrpIBrf8M7K6GauH3/KMh0cANNcH5bBOQm8IU ANt6ol+2j4pL2FO2EyqrMygjZ3pQUI2t3QV9FdELq18/r8mdfIuRyF0wb5/yt/71Z+iH VLtRbiVf7bykLS7j7tlIPgnH3srHQXlCEKYkmnSJPhYl6nXLjd+fVv9X4h3PKZIIS/pH HmHjDcKoLtsxQtloWLBywAPLme01GGZwGWB2Yvhv/U5mUVa3pgEaaIdaB2+1wwSCvZAE 6LEu8gnG/4yYzmyKt8Gw2xPF54PLCmJZDJr71nF9oYmLz8HROkdVQIuRBsrwDGi2JehS YsbA== 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=xQNCsAi0lBnoHh0vSAc+9LTFN8bCjRBhRubKfMpS//Q=; b=H02tfjREty9fsjZKCOzqAzbesMfyvn8za307Ew27DPknTy7mNnbK80bnSAUBr9zG0E AlBkt0rAFkrEG93q/wJKTSe4Ul6Ta1q9YRduxS2jYQ0WyvYRUpedHZGP106xPr5gxq1W 7MkgkcDgXJKyBbRPAoRlM+TpkVNJMBTTQMppQVBTWnpFNzPZyFxSu0czqrWi7MzaAkVW vgZJipDbbYYTZkZRWxgTm+0s613DIIA4uwWUJa4aU6z5+ORflIi27xRmUkwzApjtt5GA 3PnwS394+4ARvsuwQ+YRuTzqLFTTATGC5kWJdTKL1IQ56tRMxdr+Qghi1BgwLMkq2xi9 VIrg== X-Gm-Message-State: AMke39lkjWqwf915/Iy/bPcaPd993ZL4ay/pC6lErEMcKUOKVVxTdHijE1XYFL/IEhkWd4yNREjaH5GR+Z3kCQ== X-Received: by 10.200.39.77 with SMTP id h13mr33012174qth.62.1487145158107; Tue, 14 Feb 2017 23:52:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.35.90 with HTTP; Tue, 14 Feb 2017 23:52:37 -0800 (PST) Received: by 10.200.35.90 with HTTP; Tue, 14 Feb 2017 23:52:37 -0800 (PST) In-Reply-To: References: Date: Wed, 15 Feb 2017 08:52:37 +0100 Message-ID: To: Levi Morrison Cc: Dan Ackroyd , PHP Internals List Content-Type: multipart/alternative; boundary=001a11405bace0eab505488cf652 Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object type hint, now with added variance From: ocramius@gmail.com (Marco Pivetta) --001a11405bace0eab505488cf652 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Levi, On 14 Feb 2017 10:20 p.m., "Levi Morrison" wrote: On Tue, Feb 14, 2017 at 2:14 PM, Levi Morrison wrote: > On Tue, Feb 14, 2017 at 11:55 AM, Dan Ackroyd wrote: >> Hi Levi, >> >> On 24 November 2016 at 08:58, Dan Ackroyd wrote= : >>> Hi Levi, >>> >>> On 23 November 2016 at 01:25, Levi Morrison wrote: >>> >>>> For instance enumerations (or enums) are one possible type I can see u= s >>>> adding that may not be objects. >>> >>> I very much look forward to the RFC for enums, and have for some time. >>> When are you thinking of submitting it for discussion and voting? >> >> I can understand your concerns. At the same time, I hope you can >> understand that people won't want to put off introducing features that >> they want in the meantime. >> >> I think if you were able to give a timeline for when an Enum RFC could >> be introduced, before the PHP 7.2 release, we could talk about whether >> it would be right to hold off on this RFC for now. >> >> Otherwise I suggest Micha=C5=82 updates the voting options, and we open = the >> voting in a week or so. >> >> cheers >> Dan > > Let me clarify that I'm not against this object variance; there is > nothing intrinsic about object variance that prevents enums (or > typedefs/type aliases). Rather it's *how* it is achieving that > variance that is an issue. This is something that should ship along > with full covariance/contravariance and not be a special case which > may unintended side-effects later (such as preventing enums without > breaking BC). Does that make sense? Here's a concrete compatibility concern. Let's assume we have the following code: interface Factory { function make(...$args): object; } class FooFactory { function make(...$args): Foo; } Currently the engine would not have to know anything about Foo to know if it is a sub-type of object. It would not need to require it to even be defined. However, if at some point in the future we add non-object types it may now error or autoload. Since the engine is clueless about types until autoloading happens, this is easily solvable by providing a marker syntax for non-object hints. For instance `function foo() : enym:MyEnum {}` The current (and valid) assumption by both the engine and userland reflectors is that anything after the `:` in a return type declaration is one of: * bool * array * int * float * string * callable * void * $classOrInterfaceName Regardless of this RFC, and considered that `object` is an already reserved keyword, you can't use the same syntax for enum types anyway, since you're going to break a crapton of userland code. The way to avoid the compatibility concern is to implement this feature the same way we wold implement full covariance, which would similarly need to know about the types involved. Does that make more sense as to why the assumption that unknown types are object types is an issue? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php Given inline comments above, can we archive the enum discussion? --001a11405bace0eab505488cf652--