Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63411 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69921 invoked from network); 15 Oct 2012 13:29:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Oct 2012 13:29:50 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:40663] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 41/94-42204-CCF0C705 for ; Mon, 15 Oct 2012 09:29:49 -0400 Received: by mail-pb0-f42.google.com with SMTP id ro2so4977873pbb.29 for ; Mon, 15 Oct 2012 06:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=/3Q8rzqIX7mRtQ/TzB/iOFWaREAPc691+OE//gJzN+g=; b=Nb8WczUyIylbD9UlXjI4PtXduR24WW4O/nhFBCR3u48FZhmUwwOTGZGjCRPgRQ3zAd /6VjsuXVE6nL0b/a+zTjbjOZ6Lb/fyzD7OCGj60frZl1SDgImh0wRjlrTzQ3jJaeTDLk a3ovatD1hTbkwSrQ6bz1nCSJ6enssmVZQYn+SMa3Yg24k6DGwjXsWN2g4BkUrCdANP1N JzW+8nG9oFVt/5aJjnjK20pDS0e9uwu9ORKEVsomERfEwNY0NY+W6/wFUKkp0hVL8dRE xI9S4YP924UD2XKxnMHmGEUfRy7qTWmIftjdh8quuNsfE8C1GFTGBIwxj5pZ6ygnWmk8 GO8w== Received: by 10.68.221.166 with SMTP id qf6mr37159332pbc.54.1350307786160; Mon, 15 Oct 2012 06:29:46 -0700 (PDT) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.68.144.42 with HTTP; Mon, 15 Oct 2012 06:29:25 -0700 (PDT) In-Reply-To: <9570D903A3BECE4092E924C2985CE485612B6466@MBX202.domain.local> References: <9570D903A3BECE4092E924C2985CE485612B6466@MBX202.domain.local> Date: Mon, 15 Oct 2012 15:29:25 +0200 X-Google-Sender-Auth: GeX6d5xafBsdNhPZOb49EuD-jSg Message-ID: To: Clint Priest Cc: "Nikita Popov (nikita.ppv@gmail.com)" , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [PHP-DEV [RFC] Property Accessors v1.2 : Interfaces From: colder@php.net (Etienne Kneuss) Hi, > > Interfaces are a tough one, I would just like to point out that, again ac= cessors are fundamentally different than properties, they just happen to sh= are the same "use" syntax but act entirely differently. The difficulty wit= h allowing an interface to enforce a property is that the implementing clas= s doesn't know when that property has changed or been accessed, whereas wit= h an accessor they are required to write code that responds to the use of t= he property. > > > > I hate to keep pointing to C# but (IMHO) it's a leader in terms of functi= onality for a language and PHP is so similar to the C* family of languages = it would follow suit that we should continue that direction as its probably= one of the reasons it has grown in popularity so much (any C* programmer c= an write PHP with minimal new understanding, and new programmers are expose= d to an easy language which mimics some of the best other languages out the= re); and thus, C# specifically permits accessors within an interface. > > > > I have no personal stake in this desire to keep them as I do not use inte= rfaces (very often) but from a purist point of view on the concept of inter= faces I wanted to finish this up with an example of an interface that could= exemplify why they should be allowed: > > > > interface iVehicle { > > public $TireCount { get; } > > public $EngineType { get; } > > public $IsFunctional { get; } > > public $Speed { get; } > > > > public $OutputLocale { get; set; } /* Do we output MPH o= r KPH, for example) > > > > public function Drive(); > > } Interfaces are defined to specify how a an object implementing a certain interfaces can be used. The clear indication of this is that only public methods are allowed in interfaces. For instance, an interface A with a get accessor on the property "foo" will only tell you that, given that $obj implements A, you will be able to read $obj->foo. In fact, the following code interface A { public $a { get; set } } class B implements A { public $a; } should be valid. In terms of capabilities, the class B implements all the requirements imposed by the interface A. (The same goes if A was a class, BTW) Is that the case in your current patch? (I couldn't find information in your RFC nor in the tests on github) If it is the case, I'm fine with having accessors and not plain properties in interfaces. Best, > > -Clint --=20 Etienne Kneuss