Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78769 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45047 invoked from network); 6 Nov 2014 02:01:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2014 02:01:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.169 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.214.169 mail-ob0-f169.google.com Received: from [209.85.214.169] ([209.85.214.169:59088] helo=mail-ob0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/03-28384-B66DA545 for ; Wed, 05 Nov 2014 21:01:15 -0500 Received: by mail-ob0-f169.google.com with SMTP id va2so123054obc.28 for ; Wed, 05 Nov 2014 18:01:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=dnGiKK4wqUwyXc7sNTriA7J4/nVxNr8XW23x02aBL/Q=; b=M4eNuKb27RJ1eiQwM5fOa2FOGUiMrkWJoD+4quBtu3XfG9x92gZXRF2non5RlGsKZ5 +ey14B9V7BoIHKC7QxD94uzDrSrGxga6z2m2jasaHb0Gxw3CgruRQoZ+jzPUAFehY4CG fQJBF8N0ZHCAPtak8Od8wyymDAqeCwLh5NywVoaV8q/URaAp1MkeABRXotsLVBTY6w2i yb1TWpTj+8rXVD6xy6hccHJ2hYPHunsTQGhbvljBH9EX+5hGD2yo3vsRKjja07U6ABD3 tVw9n3NCe3B2AMQ6TvlNGivIps5YK9gynuKk9L9feMiMgBowl4s3G+3iUy4ZV86Pkepl 2tVA== MIME-Version: 1.0 X-Received: by 10.202.66.214 with SMTP id p205mr965565oia.10.1415239272588; Wed, 05 Nov 2014 18:01:12 -0800 (PST) Received: by 10.76.159.163 with HTTP; Wed, 5 Nov 2014 18:01:12 -0800 (PST) In-Reply-To: <5BB43ECD-089D-4DDD-AD95-1263B05279CB@ajf.me> References: <5B1B375C-328B-40BD-B715-8EDA158B44CE@ajf.me> <545A912A.2050202@sugarcrm.com> <545AA193.6060606@sugarcrm.com> <3E396F3F-CD59-4198-8FD2-1A8C4ED3B87A@ajf.me> <5BB43ECD-089D-4DDD-AD95-1263B05279CB@ajf.me> Date: Wed, 5 Nov 2014 19:01:12 -0700 Message-ID: To: Andrea Faulds Cc: Stas Malyshev , Dmitry Stogov , internals , Nikita Popov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Vote] Return Types From: morrison.levi@gmail.com (Levi Morrison) To demonstrate the value of covariance and why `static` alone is not sufficient, here is a small example: interface Enumerable extends \IteratorAggregate { function getIterator(): Enumerator; } class Vector implements Enumerable, \ArrayAccess, \Countable { function getIterator(): VectorEnumerator { /* =E2=80=A6 */ } } class VectorEnumerator implements Enumerator, \Countable { /* =E2=80=A6 */ } This shows why covariance is important for two reasons: First, it shows that static isn't sufficient. The VectorEnumerator is not the calling class, so self and static are not applicable. Second, without covariance you could only declare a return type of Enumerator for Vector::getIterator(); a calling class couldn't rely on the properties of a VectorEnumerator that are unique to it, such as \Countable.