Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103522 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 8810 invoked from network); 28 Nov 2018 00:40:59 -0000 Received: from unknown (HELO mail-ot1-f45.google.com) (209.85.210.45) by pb1.pair.com with SMTP; 28 Nov 2018 00:40:59 -0000 Received: by mail-ot1-f45.google.com with SMTP id 32so21453909ota.12 for ; Tue, 27 Nov 2018 13:04:42 -0800 (PST) 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=l8wLkD1Y0DIBuhNO3jUIdxPCagOQ0A02WTctb7rBV6Q=; b=HMcrtaLhMK/h8a1BQ+sHssI3meYzTlCZNJBR85Rf+oH+yYIcq2ZcZS0LXmBvM5xsG2 EO4hkw0I5O9NTbMVVhpLvz24B9bEn8CGTD7XsYEDgV/L8xfo8UD/FAxTT53XLKXJtXkt pakjme555qxmpxcIS7Hq7O4qmH6Rlh2F+2Us0I4kf7adOISNFs+toyKbBT0hTJwSHqYt ZoWAYd4xnatZRLYS6vqc6VXg2A8lMfSmI6siHBiAeE1IEPquLJfdgnOBtP4zzbHbt04D wFHQVD5GmU1FuUff5/sOvv72ozr/YeuESheuHttgkfOtTmxXiCV3Bz6rS+wvBDObWRba ICSQ== 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=l8wLkD1Y0DIBuhNO3jUIdxPCagOQ0A02WTctb7rBV6Q=; b=rv+UijvcNcyfjyHzO9NeX9uKSi5Fi6CgeqvlvYP8M3Jn/FcLFSApXkxc6ksFuW21R6 Es+4EdKEhd9cNj9AmZE8GOrivtaYrUT6XZ4L96tJmAYIhobnYRbB1HLXMihozS3FBwkS qFkMSfSXotagOUbDzypaGLmEMGUJspbBolSEhdeTFQB7QQNincNDiRtY1amNvjMpkMZC BO1m51LOwf/nY2Si2V3XZLX2MbJX3oXO7dniXAyqCRG9cF25RnVphbyKWHaCOKJsVZNa uXRRjgM1Zb1N6A6TSG6qHjWo5snZbBGNkeZKPDY9knPd+vp0PxbozaJv0GecBVgMqem8 6QSA== X-Gm-Message-State: AA+aEWYaZtfBF6nRCuAB8AM0ug4dhvXUC/dwLPeEHkSPcuvYT/uNeS2T K8qk3/95kG4lDPppaD+7PPUK+MgySUNkEU2SdIEZjp2H X-Google-Smtp-Source: AFSGD/VdmdcBY2/ZrrnyfIv0tY6dSQisNeKRlEtVXCSX9mjClkfd+DHneEsQGY1j7kWqp/ImaVFMTuAvIhj3+WZpkrk= X-Received: by 2002:a9d:2f64:: with SMTP id h91mr3537474otb.14.1543352681540; Tue, 27 Nov 2018 13:04:41 -0800 (PST) MIME-Version: 1.0 References: <2701692.XuXcyRlYA4@vulcan> In-Reply-To: Date: Tue, 27 Nov 2018 19:04:30 -0200 Message-ID: To: Levi Morrison Cc: larry@garfieldtech.com, internals Content-Type: multipart/alternative; boundary="00000000000058b412057babccb8" Subject: Re: [PHP-DEV] [RFC][Discuss] Covariant return- and contravariant parameter- types From: marcospassos.com@gmail.com (Marcos Passos) --00000000000058b412057babccb8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Supporting `static` return would come in handy to define interfaces for immutable objects. Em ter, 27 de nov de 2018 =C3=A0s 19:01, Levi Morrison escr= eveu: > On Tue, Nov 27, 2018 at 11:36 AM Larry Garfield > wrote: > > > > On Monday, November 26, 2018 3:25:52 PM CST Levi Morrison wrote: > > > I am happy to announce my latest RFC, [Covariant Returns and > > > Contravariant Parameters][1], is open for discussion. If you do not > > > recognize those terms then hopefully the introduction coupled with th= e > > > [examples][2] will help. Here is one snippet that demonstrates > > > covariant return types: > > > > > > > > interface Repository { > > > function fetch(int $id): ?Entity; > > > } > > > > > > class UserFactory implements Repository { > > > function fetch(int $id): ?UserEntity { > > > /* Since UserEntity is an Entity, this is now allowed */ > > > /* ... implementation ... */ > > > } > > > } > > > ?> > > > > > > Covariant return types and contravariant parameter types are highly > > > requested features; here are a few of the bug reports: > > > > > > * https://bugs.php.net/bug.php?id=3D71825 > > > * https://bugs.php.net/bug.php?id=3D72442 > > > * https://bugs.php.net/bug.php?id=3D75385 > > > * https://bugs.php.net/bug.php?id=3D75823 > > > > > > There is a [preliminary implementation][3] that is available. It will > > > not be rebased during discussion to allow people to check out the cod= e > > > and get updates without worrying about it breaking. The code quality > > > can definitely be improved, and there are still a few todo comments i= n > > > the code. > > > > > > Please do not discuss the items found in [Future Scope][4] as part of > > > this thread, which includes discussing types such as `mixed`, > > > `scalar`, `numeric`, etc. > > > > > > I look forward to your feedback, and especially with your > > > experimentation with the implementation. > > > > > > Levi Morrison > > > > > > [1]: > > > > https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters > > > [2]: > > > > https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters#e= xa > > > mples [3]: > > > https://github.com/php/php-src/compare/master...morrisonlevi:variance= 2 > [4]: > > > > https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters#f= ut > > > ure_scope > > > > Looks like fun! > > > > Would this also include allowing a return type of `static`, which would > be > > useful for the "Return the object that was invoked" case or "return a n= ew > > instance of the same object" case? Currently we're limited to `return > self`, > > which is, of course, not the same thing and less flexible. > > > > --Larry Garfield > > It does not. To be honest, I did not think of it until your question. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --00000000000058b412057babccb8--