Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23309 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39389 invoked by uid 1010); 12 May 2006 15:40:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 39374 invoked from network); 12 May 2006 15:40:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2006 15:40:32 -0000 X-PHP-List-Original-Sender: bgrupe@gmail.com X-Host-Fingerprint: 64.233.182.187 nf-out-0910.google.com Linux 2.4/2.6 Received: from ([64.233.182.187:33016] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 72/89-19568-F6CA4644 for ; Fri, 12 May 2006 11:40:32 -0400 Received: by nf-out-0910.google.com with SMTP id n15so319580nfc for ; Fri, 12 May 2006 08:40:28 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=KoPGccohjBcuMFyFCFstYcn4b8ypsIjjR0GrKrBoL9OojNXFpio9JgEmzIsu3Ut/6xS8sNmezEBdjp7W7j3enIL8P89U+MibugM4XBgFZTHMXyY0d1NMY2OgAN9Dtk7d4o7yk43gUA4JOZK8DC7AHR34FrydDZ5sgTzWgLY4QcQ= Received: by 10.48.254.16 with SMTP id b16mr1214563nfi; Fri, 12 May 2006 08:40:28 -0700 (PDT) Received: from ?192.168.1.16? ( [80.128.18.134]) by mx.gmail.com with ESMTP id l27sm289955nfa.2006.05.12.08.40.27; Fri, 12 May 2006 08:40:27 -0700 (PDT) Message-ID: <4464AC64.5050706@gmail.com> Date: Fri, 12 May 2006 17:40:20 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060308 Thunderbird/1.5.0.2 Mnenhy/0.7.4.0 MIME-Version: 1.0 To: Jason Garber CC: internals@lists.php.net References: <785810036.20060511193536@ionzoft.com> In-Reply-To: <785810036.20060511193536@ionzoft.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] private, protected, readonly, public From: bgrupe@gmail.com (Bastian Grupe) Jason Garber wrote: > > Would it be possible to create a new object property attribute: > readonly > > class xx > { > readonly $bar; > } > > $o = new xx(); > > $o->bar = 10; > >>> FATAL ERROR > > > This way, PHP would allow reading (as if it were public), but only > allow writing from within the class. Uhh... how about using private and only using a "regular" getter (the Java-style) and no setter? class xx { private $bar; public getBar() { return $bar; } } $o = new xx(); $o->bar = 10; // already emits FATAL ERROR