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:

- variable for value has the same name as property
    public $Hours {
        set { $this->Seconds = $Hours * 3600; }
    }

- magic constant
    public $Hours {
        set { $this->Seconds = __VALUE__ * 3600; }
    }

- 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(); }
    }

- or at least have it in same format as superglobals
    public $Hours {
        set { $this->Seconds = $_VALUE * 3600; }
    }

What do you think?

Thanks
Denis

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to