Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:17520 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53968 invoked by uid 1010); 3 Aug 2005 23:52:55 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 53953 invoked from network); 3 Aug 2005 23:52:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2005 23:52:55 -0000 X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.4/2.6 Received: from ([204.11.219.139:60080] helo=colo.lerdorf.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 1C/EF-04646-6D851F24 for ; Wed, 03 Aug 2005 19:52:54 -0400 Received: from [10.10.13.96] (ip134.198.145.214.iinet.com [198.145.214.134] (may be forged)) (authenticated bits=0) by colo.lerdorf.com (8.13.4/8.13.4/Debian-3) with ESMTP id j73NqbG7012029; Wed, 3 Aug 2005 16:52:41 -0700 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: <39FD64FE-3B15-4E66-A4CD-C392B666BD32@gravitonic.com> Cc: PHP Developers Mailing List , Jan Borsodi , Raymond Bosman , Frederik Holljen , Tobias Schlitt Content-Transfer-Encoding: 7bit Date: Wed, 3 Aug 2005 16:52:50 -0700 To: Derick Rethans X-Mailer: Apple Mail (2.733) Subject: Re: [PHP-DEV] Property Overloading RFC From: andrei@gravitonic.com (Andrei Zmievski) On Aug 2, 2005, at 6:05 AM, Derick Rethans wrote: > Solutions: > - For problem 1. we can introduce a keyword (or use an existing > one) to define > that it is a virtual property ('abstract' or 'virtual' come to > mind). When > declaring it like this it's easy to document, and we can also > implement > visibility for those virtual properties. Marcus already has a > patch for > this somewhere, which uses the "abstract" keyword for this purpose: > > class Base > { > /** > * @var int Contains all X > */ > abstract public $x = 1; > > /** > * @var int Contains all Y > */ > abstract protected $y = 2; > > // abstract private $z = 3; abstract properties cannot be private > } > ?> The whole point of these "virtual" properties is that their names can be parameterized. If you have 1000 of these variables (in a DB or somewhere), how would you declare them as "abstract" or "virtual"? > This is ofcourse overly complicated. A better workable solution > would be - > without breaking BC (suggestions for syntax here are very welcome): > > class Base > { > abstract public $x = 1; > > function __get($name) > { > if (!self::isVirtual($name))) { > /* throw error */ > } > } > } > > $b = new Base(); > echo $b->foo; > ?> How about a __have_prop() method that you can call to find out if a certain virtual property exists? -Andrei