Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64126 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60479 invoked from network); 1 Dec 2012 12:35:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2012 12:35:04 -0000 Authentication-Results: pb1.pair.com header.from=sebastian.krebs.berlin@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.170 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.215.170 mail-ea0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:56380] helo=mail-ea0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/72-26487-779F9B05 for ; Sat, 01 Dec 2012 07:35:03 -0500 Received: by mail-ea0-f170.google.com with SMTP id d11so577280eaa.29 for ; Sat, 01 Dec 2012 04:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:x-google-sender-delegation:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=8CiPjOsaCJ7dDrF7O9mPiSeB21KRdrRl83C84kCtCvs=; b=drJ6F2l2G/TFIbkbt0ORoy0sVsLsBmuAvAlsZL5GX/nlt+XYvKfXq2JI5LQ7Q+6rBx YzEovIHGZIZXGCcztWR4Wkm5Q+7G9SzPbe1ztCYqQQX+/zA+VfECnweJupj/n9Kyj5LX CFlIu9x1wUfLjIWnLYph7oM3Iz3onxPlXMBHyQQfCJntCQuL3d7KANZK8A+j/Z0haMow rOhF+PoXo+mLX7W36ALcX/Ahw8Z3FmQDaKW+4ZhmLXsW40nfV+SHYJxnfVvitxqe4xyy paDGF55w7VgRITTx6R5DZvFYZKXZSIkUtwO/oOV5eo59PLLnANEQHpOCLI64z9WVRwCf VJoA== MIME-Version: 1.0 Received: by 10.14.223.200 with SMTP id v48mr15663019eep.24.1354365298822; Sat, 01 Dec 2012 04:34:58 -0800 (PST) Sender: sebastian.krebs.berlin@gmail.com X-Google-Sender-Delegation: sebastian.krebs.berlin@gmail.com Received: by 10.14.207.67 with HTTP; Sat, 1 Dec 2012 04:34:58 -0800 (PST) Date: Sat, 1 Dec 2012 13:34:58 +0100 X-Google-Sender-Auth: bN4X4Y3X_V9wF8Vr1pwWMhZS9xo Message-ID: To: PHP internals list Content-Type: multipart/alternative; boundary=047d7b622820884dbf04cfc9be12 Subject: Abstract properties From: krebs.seb@gmail.com (Sebastian Krebs) --047d7b622820884dbf04cfc9be12 Content-Type: text/plain; charset=ISO-8859-1 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 (and 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 define 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 --047d7b622820884dbf04cfc9be12--