Re: [RFC] Property Accessors v1.2 : Internal Accessor Method Visibility / Callability

From: Date: Sun, 04 Nov 2012 09:02:01 +0000
Subject: Re: [RFC] Property Accessors v1.2 : Internal Accessor Method Visibility / Callability
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-63739@lists.php.net to get a copy of this message
Le 26/10/2012 11:37, Clint Priest a écrit :
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
In the RFC, section "read-only / write-only keywords" :
class TimePeriod{
     private  $Seconds;
       public  $Hours  {
         get()  {  return  $this->Hours;  }
         private  final set($value)  {  throw  new Exception("Setting of TimePeriod::$Hours  is not allowed.");  }
         isset() { return isset($this->Seconds); }
         unset() { unset($this->Seconds); }
     }
}
I just added the methods "isset" and "unset" of the first example. So, is there a case where "set" and "unset" shouldn't have the same visibility ? And "get" and "isset"? If not, the Amaury's proposition could be merged in your syntax:
class TimePeriod{
     private  $Seconds;
       public:private  $Hours  {
         get()  {  return  $this->Hours;  }  // read => public
         set($value)  {  throw  new  Exception("Setting of TimePeriod::$Hours  is not allowed.");  }  // write => private
         isset() { return isset($this->Seconds); } // read => public
         unset() { unset($this->Seconds); } // write => private
     }
}


« previous php.internals (#63739) next »