Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66671 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2357 invoked from network); 17 Mar 2013 09:03:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Mar 2013 09:03:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.172 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.210.172 mail-ia0-f172.google.com Received: from [209.85.210.172] ([209.85.210.172:60576] helo=mail-ia0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/C1-19321-1F685415 for ; Sun, 17 Mar 2013 04:03:46 -0500 Received: by mail-ia0-f172.google.com with SMTP id l29so4469067iag.31 for ; Sun, 17 Mar 2013 02:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=GtKmlIaqdVJiareLkVaw/t5eUIsWqN7moCzHVL4de7Q=; b=iXGvBkHSw9OqTDC+J6eaERy56aebObE/1EYQvBshIg0i5Am7WafRQyeMzNkKdbDri/ 80r+dByAuRoALmuQRq9auA8yf1CEzINScRIPKs6BV01lQT76tLd94bXGtTI6mmAo2QB2 FA2o+u0VAYuI9UMZvGY03WmzSEIxbylcW40+7iuSV863r0Up/gxjB7bnmL+8g32lPyYZ RaXoStvzV05LOQc577JAedJD8i2fa6zs32F0kePaSu7AQWVgk1Nd6Bl7bNCVBE5WgOqj jHValmYMWCLq4oBzGTwFwo0G/xb2OPenaiulHZ1ovEX54irG5GW7Rr43VN2vIXl7IFbG KHOA== MIME-Version: 1.0 X-Received: by 10.50.212.3 with SMTP id ng3mr4503249igc.43.1363511023076; Sun, 17 Mar 2013 02:03:43 -0700 (PDT) Received: by 10.50.114.137 with HTTP; Sun, 17 Mar 2013 02:03:42 -0700 (PDT) Received: by 10.50.114.137 with HTTP; Sun, 17 Mar 2013 02:03:42 -0700 (PDT) In-Reply-To: References: Date: Sun, 17 Mar 2013 10:03:42 +0100 Message-ID: To: Sebastian Krebs Cc: PHP internals list Content-Type: multipart/alternative; boundary=14dae93409f72ddb0a04d81b2629 Subject: Re: [PHP-DEV] Abstract properties From: tyra3l@gmail.com (Ferenc Kovacs) --14dae93409f72ddb0a04d81b2629 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2012.12.01. 13:35, "Sebastian Krebs" ezt =C3=ADrta: > > Hi, > > Don't want to start a big discussion, but is there a concrete reason, why > abstract properties (or "a kind of abstract") are not supported? I've > learned, that "an interface [the concept, not the implementations within = a > language] is the sum of all accessible (--> public) methods and > properties", what as far as I understand means, that properties could (an= d > should) be defineable in concrete interfaces too > > interface Queue { > public function enqueue($value); > public function dequeue(); > public $top; > } > // or > abstract class Queue { > abstract public function enqueue($value); > abstract public function dequeue(); > abstract public $top; > } > > Of course in the second example the "abstract" is kind of useless, but it's > for illustration. I've seen some cases (for example the example above), > where it would be useful to define properties in interfaces, but instead = I > was forced to (in my eyes) misuse [1] methods. Right now I cannot safely > write somethig like > > /** > * Must have a $top property > */ > interface Queue { > public function enqueue($value); > public function dequeue(); > } > > function foo(Queue $q) { > doSomethingWithTop($q->top); > } > > Because I can never ensure, that $top exists. I always have to work with > isset() here (or of course I use a getter, as mentioned earlier), what > takes a little bit from the "usefulness" of interfaces ^^ The interface > feels incomplete. > > Would like to hear some opinions, or maybe a summary of earlier discussions > about this topic :) > > Regards, > Sebastian > > > > > [1] I've also learned, that methods define behaviour and properties defin= e > the state. "$top" in the example is part of the state, thus calling a > method to fetch the state feels wrong/like a hack (thats btw my opinion > about getters/setters too; just to create a bridge to other concepts ;)). > > -- > github.com/KingCrunch I'm also interested about the rationale behind this design decision. --14dae93409f72ddb0a04d81b2629--