I agree. It's more consistent than the $Hours solution and we don't have to add another superglobal or magic constant, which is quite nice. The typehinting is a big plus as well.
On Mon, Oct 8, 2012 at 3:26 PM, Benjamin Eberlei <kont...@beberlei.de>wrote: > The set() one is really nice with the typehints. > > On Tue, Oct 9, 2012 at 12:19 AM, Aaron Holmes <aa...@aaronholmes.net> > wrote: > > > On 10/8/12 1:07 PM, Denis Portnov wrote: > > > >> 08.10.2012 15:52, Clint Priest пишет: > >> > >>> public $Hours { > >>> get { return $this->Seconds / 3600; } > >>> set { $this->Seconds = $value; } > >>> isset<http://www.php.net/isset**> { return isset< > >>> http://www.php.net/isset**>($this->Seconds); } > >>> unset<http://www.php.net/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 = $value * 3600; } > >> } > >> > >> public $Hours { > >> set (DateTime $dateTime) { $this->Seconds = > >> $dateTime->getTimestamp(); } > >> } > >> > >> This seems like the cleanest method, in my opinion. Javascript does > this > > for object prototypes: > > http://ejohn.org/blog/**javascript-getters-and-**setters/< > 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 > > > > >