Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50770 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64770 invoked from network); 1 Dec 2010 12:17:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2010 12:17:16 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:49297] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 93/60-62427-BCC36FC4 for ; Wed, 01 Dec 2010 07:17:16 -0500 Received: by qyk10 with SMTP id 10so2386249qyk.8 for ; Wed, 01 Dec 2010 04:17:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:reply-to :in-reply-to:references:from:date:message-id:subject:to:cc :content-type; bh=26z44kzInOOm1Enth6vZ66Hb9VuYPGO91nGR2pRRNKg=; b=Obd12oylLdgBveK5zPEL1VKyp/euv6jUcNhpPpS46fF0xAcUjYU3UH1N9xsV4W49zF Ljju37eTAR3lL97kAgojjZhqEovQ0l9IgL3XXH5V7JemTON+q+qfggokaeU03jBfaAbo Xb9wa//QPBTNzEOqQvugwx4TS42Bweqvp/bgw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; b=DeANWfs6APJvg6/IFkR0WyfE3vMo8u9REe0tKEAGdU7JqxrFuGQE8rhgXhTc7WmKX5 WTWYOcI5H0Si5qAORQSVk9uCP15pb/P2u1vMmoHZT1+69rYLzL1x8XnDaBtHnY5R0PZn JNfFyEEsavu9EbMSZOW/jN1QO3jH9kKdSGO+k= Received: by 10.229.212.72 with SMTP id gr8mr7248409qcb.177.1291205833250; Wed, 01 Dec 2010 04:17:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.130 with HTTP; Wed, 1 Dec 2010 04:16:52 -0800 (PST) Reply-To: RQuadling@googlemail.com In-Reply-To: <4CF625C2.1080606@sugarcrm.com> References: <003601cb8fd0$f6494e80$e2dbeb80$@com> <4CF3B855.5010406@sugarcrm.com> <003401cb8fee$1be39840$53aac8c0$@com> <2450924ae03481f5b1382a7f00e5743d.squirrel@webmail.basnetworks.net> <4CF50245.5020807@sugarcrm.com> <4CF5118B.2030300@sugarcrm.com> <1faa4c3db62771335db714507ac2adfa.squirrel@webmail.basnetworks.net> <4CF613EB.40200@sugarcrm.com> <4CF625C2.1080606@sugarcrm.com> Date: Wed, 1 Dec 2010 12:16:52 +0000 Message-ID: To: Stas Malyshev Cc: "president@basnetworks.net" , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP From: rquadling@gmail.com (Richard Quadling) On 1 December 2010 10:38, Stas Malyshev wrote: > So we have one set of properties where get and isset use different methods > and another set of properties where get and isset use same method but with > parameter. I think it's not the best way to go. It's better to ignore isset > altogether than this. No. The prototype of all setters would be the same. As would the prototype of all getters. The prototype would be ... [public|protected|private] property $property { [public|protected|private] mixed|bool get([bool $isset = false]) { // mixed result for get, bool result for isset }, [public|protected|private] mixed|void set(mixed $value [, bool $unset = false]) { // mixed result for set, void result for unset }, }; From a user's perspective ... echo isset($instance->property) ? 'isset to ' . $instance->property : 'not isset'; This would result in 2 calls ... property->get(true) // Let the getter that an attempt is being made to see if the property has been set. and property->get(false) // Let the getter know that the getter is expected to return the properties value. Similarly for the setter. $instance->property = 'foo'; unset($instance->property); would result in 2 calls ... property->set('foo', false) // Let the setter know that it should be setting the value of the property to 'foo'. and property->set(null, true) // Let the setter know that an attempt to unset the property has taken place. Maybe the proposal should be changed to ... [public|protected|private] property $property { [public|protected|private] mixed get() { }, [public|protected|private] mixed set(mixed $value) { }, [public|protected|private] bool isset() { }, [public|protected|private] void unset() { }, }; (NOTE: Add in abstract and final as appropriate). -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY