Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63286 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12274 invoked from network); 8 Oct 2012 22:27:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Oct 2012 22:27:04 -0000 Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 209.85.217.170 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:42197] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/80-07968-53353705 for ; Mon, 08 Oct 2012 18:27:03 -0400 Received: by mail-lb0-f170.google.com with SMTP id gm13so3357361lbb.29 for ; Mon, 08 Oct 2012 15:26:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=7y2hEqgd0T2iWoaB/QnxJPE+mtmE3jLKoOITvV/uI6Y=; b=QKHiEx6ClPZ9jOC+wcdlkLMw0ytisu0q+7TYFAoHM8QZRJv4TT8rLuwNbztHPPMPZG ZtwX9n9nguoRGF9O6pment38BpOY5hlmc5kDnKMvEZXSaKmp5UsvVeWvXGsBgbbuU86q uzXMJVn/tUREmGrTlKmOm64eh47BHt6odPfOtVgnbR91cmic6yAr0VGIYNbDei32tVZm XAm9XEbD4wIEAq1xI7jEJc51ag/1DG2kOhfEzBDxglXHI9O9LhVAkbCV3KRBfahMocIk u/V2lxYXhE7C6IJ+R5SXlvECMRADU3E6V1gySorwvKwix+U9UXBec9rzB4fhe3LXrOjM TG9g== MIME-Version: 1.0 Received: by 10.152.103.243 with SMTP id fz19mr15000422lab.27.1349735219129; Mon, 08 Oct 2012 15:26:59 -0700 (PDT) Received: by 10.112.132.102 with HTTP; Mon, 8 Oct 2012 15:26:59 -0700 (PDT) X-Originating-IP: [77.11.87.97] In-Reply-To: <50735165.8010703@aaronholmes.net> References: <9570D903A3BECE4092E924C2985CE485612B3B48@MBX202.domain.local> <5073328D.5000002@gmail.com> <50735165.8010703@aaronholmes.net> Date: Tue, 9 Oct 2012 00:26:59 +0200 Message-ID: To: Aaron Holmes Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d04083a8b46ee3f04cb93b8fa X-Gm-Message-State: ALoCoQl+lFF0+qf5ZMO+lk9C4rANSjO78ohEJ2XEYCVpRxTNwfX5nLcdcYYSJtTRUVHV9SfQWa16 Subject: Re: [PHP-DEV] [RFC] Propety Accessors v1.1 From: kontakt@beberlei.de (Benjamin Eberlei) --f46d04083a8b46ee3f04cb93b8fa Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The set() one is really nice with the typehints. On Tue, Oct 9, 2012 at 12:19 AM, Aaron Holmes wrote= : > On 10/8/12 1:07 PM, Denis Portnov wrote: > >> 08.10.2012 15:52, Clint Priest =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> >>> public $Hours { >>> get { return $this->Seconds / 3600; } >>> set { $this->Seconds =3D $value; } >>> isset { return isset< >>> http://www.php.net/isset**>($this->Seconds); } >>> unset { unset< >>> http://www.php.net/unset**>($this->Seconds); } >>> } >>> >> >> >> Hi Clint, >> >> I've noticed some magic variable '$value' is introduced. And except for >> superglobals I guess there is no such thing in PHP, so it looks bit >> puzzling to me. I'd suggest on of the following: >> >> >> - setter resambles setter method, wich also allows typehinting >> public $Hours { >> set ($value) { $this->Seconds =3D $value * 3600; } >> } >> >> public $Hours { >> set (DateTime $dateTime) { $this->Seconds =3D >> $dateTime->getTimestamp(); } >> } >> >> This seems like the cleanest method, in my opinion. Javascript does thi= s > for object prototypes: > http://ejohn.org/blog/**javascript-getters-and-**setters/ > > >> >> What do you think? >> >> Thanks >> Denis >> >> > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --f46d04083a8b46ee3f04cb93b8fa--