Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103520 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 80642 invoked from network); 27 Nov 2018 22:13:00 -0000 Received: from unknown (HELO out4-smtp.messagingengine.com) (66.111.4.28) by pb1.pair.com with SMTP; 27 Nov 2018 22:13:00 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 1BC2322D06 for ; Tue, 27 Nov 2018 13:36:42 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 27 Nov 2018 13:36:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=7+HaeX 9eeeE4Z94W6D77fPvSW11ofVWpTCLMTPQm3FI=; b=Uyav3GqtED1vsp8JhhIltp h934soP7wLrIdzxaWnFx3QX1YJCbV4Ip0OXDDyohGnFE59b05pBg+OlTaBbrMm9t cTHVgnnEMwfhMyQ+M3ovd95T5Q06XQAHfaAUwtloES/TVo/PCT6RvI/DNMGieNrV VNklCrsplberMzccc9KepddUaxS1hdokera3uVLxF4cEEK4G5ju+njo/5XHK5nbM yYseJDZ4Bw7wc8HgtaC6tCBWOjhLWaXqjcm9YBl08kPRs9y6AM9cST2RP7ZmKznj yTp7smQgxbhUdkelWepL0Wfvj7uAh6b2zJDk1nWS+kC5eBbrousSnRGHEloWATfQ == X-ME-Sender: X-ME-Proxy: Received: from vulcan.localnet (216-80-30-152.s3222.c3-0.frg-cbr1.chi-frg.il.cable.rcncustomer.com [216.80.30.152]) by mail.messagingengine.com (Postfix) with ESMTPA id 0EDD5E49CB for ; Tue, 27 Nov 2018 13:36:41 -0500 (EST) To: internals@lists.php.net Date: Tue, 27 Nov 2018 12:36:37 -0600 Message-ID: <2701692.XuXcyRlYA4@vulcan> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart9833754.66Mn9bIGb9"; micalg="pgp-sha512"; protocol="application/pgp-signature" Subject: Re: [PHP-DEV] [RFC][Discuss] Covariant return- and contravariant parameter- types From: larry@garfieldtech.com (Larry Garfield) --nextPart9833754.66Mn9bIGb9 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 the > [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=71825 > * https://bugs.php.net/bug.php?id=72442 > * https://bugs.php.net/bug.php?id=75385 > * https://bugs.php.net/bug.php?id=75823 > > There is a [preliminary implementation][3] that is available. It will > not be rebased during discussion to allow people to check out the code > and get updates without worrying about it breaking. The code quality > can definitely be improved, and there are still a few todo comments in > 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#exa > mples [3]: > https://github.com/php/php-src/compare/master...morrisonlevi:variance2 [4]: > https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters#fut > 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 new 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 --nextPart9833754.66Mn9bIGb9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEE/ph/GXfY8v0YwFBp4MMKwDFxYXcFAlv9jrUACgkQ4MMKwDFx YXfMRgf/Q1fwlljLvGaXknFV7fto4rWuEYCklgGvkegvHqTHRGEZR+lNdDbaIjOn XhOuZBy4w30BQtF0C/F+foV4CjBGaD+iDgyWqI1LmdXFxDeXOV6uz0GXeajAdsdq iUQpZulGIqGYiZXZrM8RuhlCDh4UoPzvevL1I6hWbU5xVB/oL15tFnCRfzvP7Fv2 8vbp98a2u14gqT5d0vP8ZeEXE8L7xw4JCA66SPCKPhiiPuaMYq2Bsc8xQBSW/YJL z8E3J+X5NDZnZOMxMQg9j1B3vVfYY8FjQK7mg/3edFyV54R4krZixQC6YvTDS43c dg1jwofv2/m6f2MZ9NU9sXsJgHwrcg== =fYGF -----END PGP SIGNATURE----- --nextPart9833754.66Mn9bIGb9--