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
     }
}

Reply via email to