Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23311 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59134 invoked by uid 1010); 12 May 2006 16:14:34 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 59119 invoked from network); 12 May 2006 16:14:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2006 16:14:34 -0000 X-PHP-List-Original-Sender: pollita@php.net X-Host-Fingerprint: 69.12.155.130 69-12-155-130.dsl.static.sonic.net Linux 2.4/2.6 Received: from ([69.12.155.130:4817] helo=pigeon.alphaweb.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id CC/7C-19568-964B4644 for ; Fri, 12 May 2006 12:14:34 -0400 Received: from localhost ([127.0.0.1] helo=OHRLVN4523SG) by pigeon.alphaweb.net with smtp (Exim 4.10) id 1FeZeX-00013X-00; Fri, 12 May 2006 08:34:05 -0700 Message-ID: <005101c675df$20627cc0$88051fac@OHRLVN4523SG> To: Cc: References: <785810036.20060511193536@ionzoft.com> <7.0.1.0.2.20060512082920.040b4040@zend.com> Date: Fri, 12 May 2006 09:14:20 -0700 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 Subject: Re: [PHP-DEV] private, protected, readonly, public From: pollita@php.net ("Sara Golemon") >> __get() and __set() are great, but 90% of the time, I find myself >> using them to create public readonly properties. >> >I can see where it could come in handy but I honestly think it'd be bloat. > We have to relax with the OO features because the increased code size has > already made it harder to maintain and it has the potential to make PHP > far more complicated than what it should be. > An extension could accomplish this by exporting an interface which overrides the object's read_property() method. One could "flag" which properties are allowed to be accessed r/o by giving them a distinct name e.g.: class foo implements ReadOnlyProperties { private $__ro__bar; function __construct($val) { $this->__ro__bar = $val; } } $f = new foo(123); var_dump($f->bar); The special getter sees that bar isn't in the properties table and looks for __ro__bar instead (overriding visibility restrictions in the process). Since there's no write_property override, the prop remains unwritable from outside of the object. -Sara