Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:17574 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3648 invoked by uid 1010); 7 Aug 2005 18:29:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 3632 invoked from network); 7 Aug 2005 18:29:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Aug 2005 18:29:20 -0000 X-Host-Fingerprint: 82.94.239.5 jdi.jdi-ict.nl Linux 2.5 (sometimes 2.4) (4) Received: from ([82.94.239.5:53295] helo=jdi.jdi-ict.nl) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 16/02-04646-FF256F24 for ; Sun, 07 Aug 2005 14:29:20 -0400 Received: from localhost (localhost [127.0.0.1]) by jdi.jdi-ict.nl (8.12.11/8.12.11) with ESMTP id j77ITGdi003759 for ; Sun, 7 Aug 2005 20:29:16 +0200 Received: from localhost (localhost [127.0.0.1]) by jdi.jdi-ict.nl (8.12.11/8.12.11) with ESMTP id j77ITBBR003746; Sun, 7 Aug 2005 20:29:12 +0200 Date: Sun, 7 Aug 2005 20:29:16 +0200 (CEST) X-X-Sender: derick@localhost To: Ilia Alshanetsky cc: internals@lists.php.net In-Reply-To: <42F64DC8.2000205@prohost.org> Message-ID: References: <42F64DC8.2000205@prohost.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at jdi-ict.nl Subject: Re: [PHP-DEV] Property Overloading RFC From: dr@ez.no (Derick Rethans) On Sun, 7 Aug 2005, Ilia Alshanetsky wrote: > Derick Rethans wrote: > > Problems: > > 1. There is no way to document the 'virtual' properties with any of the > > existing > > documentation tools (such as phpdoc and doxygen) > > Rather then adding abstract properties, why not simply document the possible > values inside the doc comments ala: > /** > * @var abstract int Contains all X > */ That would work, if __set and __get were also called for declared properties... but they don't do that so you need some keyword - or break BC. > > 2. There is no way how the magic methods know if a specific 'virtual' > > property > > exists or not as those properties are not declared usually - unless you > > define an array with property names as a class constant (which is not > > allowed either). > > That's the whole concept behind the feature, if the values were known you may > as well use clearly declared property and method names. True, unless you want to force all property access to go through a setter/getter for all declared properties for checks. This is also useful for catching typoes: fo = 42; ?> does not throw any notice now for BC reasons. > > 3. There is no way for the magic methods to return a meaningfull > > error when a property doesn't "exist". Of course it is possible > > to throw an error with "trigger_error" or "throw" in case a > > property doesn't "exist" in a specific class, but the file and > > line numbers would not match the actually get/set action. > > debug_backtrace() can be used to retrieve the correct file and > > line, but as you have to do this for every class where you want > > to use setters and getters *and* you have to implement your own > > error message rendering function this is not really a suitable > > option either. > > How about adding a 3rd optional argument to __get and __set which would be an > array of acceptable values for the "name" parameter? If there is a mismatch a > standard warning message will be raised if this parameter was supplied. How does the engine know which list is allowed? The engine is calling the __set and __get methods, not users. The whole idea of using a keyword here is to provide the engine with such a list. Derick