Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63333 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99805 invoked from network); 11 Oct 2012 01:56:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Oct 2012 01:56:25 -0000 Authentication-Results: pb1.pair.com header.from=davidkmuir@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=davidkmuir@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.42 as permitted sender) X-PHP-List-Original-Sender: davidkmuir@gmail.com X-Host-Fingerprint: 209.85.220.42 mail-pa0-f42.google.com Received: from [209.85.220.42] ([209.85.220.42:52582] helo=mail-pa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/61-27252-84726705 for ; Wed, 10 Oct 2012 21:56:25 -0400 Received: by mail-pa0-f42.google.com with SMTP id fa1so1229797pad.29 for ; Wed, 10 Oct 2012 18:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=e9Z3idQnrCDpWXRL2Z03wncjwULEs0rtRleS6k2bNzE=; b=d3KNpQRKEVkVjRF32/yfg+ZdZRlkfD2vTbHnZwqqd58b3Hpd/urVrFp1aRT59LLpLm gyUjgCTnyMYaCg40Qrcc8C9BW1S7XqsX4JpLsEsrG0gD7UKH3i0lsi75NjQ8TEvBDKni 0SeEscHHgU3Ya8kKCYvQW2a+go4R9MEXPOzdwFlchJAWGViho+EQBJqWWpYVtZvJmqmW oJj2l+miURbXflGwn1mUvQMSoc6ENryb1OmCWiGAi80VbJKKD0S5nQFPTcZGm4wEwYtc E10Ha3Fjz1Y1SdJ79ly10WUXt4GhaYrMXlAyzOufuYj41vyG2B0w4AV7r3FfCjg9o9+S c20Q== Received: by 10.66.83.129 with SMTP id q1mr67203581pay.4.1349920582563; Wed, 10 Oct 2012 18:56:22 -0700 (PDT) Received: from [192.168.1.181] (tmwpho1.lnk.telstra.net. [110.142.207.74]) by mx.google.com with ESMTPS id uq5sm1873766pbc.56.2012.10.10.18.56.18 (version=SSLv3 cipher=OTHER); Wed, 10 Oct 2012 18:56:21 -0700 (PDT) Message-ID: <50762747.4050304@gmail.com> Date: Thu, 11 Oct 2012 12:56:23 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: Jazzer Dane CC: Leigh , Bernhard Schussek , "internals@lists.php.net" References: <9570D903A3BECE4092E924C2985CE485612B3B48@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B496D@MBX202.domain.local> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Propety Accessors v1.1 From: davidkmuir@gmail.com (David Muir) On 10/10/12 21:41, Jazzer Dane wrote: > Here's my feedback on some current outstanding issues/suggestions: > > 1) Default value: I think having functionality for a default value is > necessary, but I'm also thinking it may already be implementable within the > current syntax. > >> class Test { >> private $seconds; >> public $hours { >> get() { >> if(!is_null($this->seconds)) { >> return $this->seconds; >> } else { >> return 10; // 10 is default >> } >> } >> } >> } >> > The above should work fine in many scenarios, right? > We could perhaps then claim that the issue may rather be that we need > access to the variable *$hours* itself inside of the get/set/etc functions, > which I think has been brought up before - though I'm not so sure how > sensible that is. Whether we need that or not is up in the air. > I think the syntax for defaults would be: class UsingInitialValue { private $seconds = 36000; public $hours { get() { return $this->seconds/3600;} } } class UsingLazyLoad { public $seconds { get() { return $this->seconds = 36000;} set($value) {$this->seconds = (int) $value;} } } class UsingConstructor { public $seconds { set($value) {$this->seconds = (int) $value;} } public function __construct(){ $this->seconds = 36000; } } I think I've got those all right... Cheers, David