Re: [RFC] Property Accessors v1.2 : Extra shorthand declaration

From: Date: Sun, 28 Oct 2012 02:41:14 +0000
Subject: Re: [RFC] Property Accessors v1.2 : Extra shorthand declaration
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-63680@lists.php.net to get a copy of this message
On 10/26/2012 05:43 AM, Clint Priest wrote:
I'm opening up several new threads to get discussion going on the remaining "being debated" categories referenced in this 1.1 -> 1.2 change spec: https://wiki.php.net/rfc/propertygetsetsyntax-as-implemented/change-requests ------------------------------------------------------------------------ *Extra shorthand declaration* Allow extra short declaration of an accessor: class TimePeriod {
    public DateTime $date;
} /* Would be equivalent to this */ class TimePeriod {
    public $date {
        get() { return $this->date; }
        set(DateTime $value) { $this->date = $value;}
    }
} ------------------------------------------------------------------------ Thoughts?
My knee-jerk response is that I'd love to be able to do public DateTime $date; it's nicely self-documenting and gives me very simple type safety (and therefore a clear and useful error thrown in my face, rather than a mystery bug later). That said, I think that goes back to my mental model question in my previous post, and I can't fully endorse this without knowing my mental model. --Larry Gafield

« previous php.internals (#63680) next »