Re: Re: [PEPr] Comment on Networking::Net_Nmap
| From: | Luca Corbo | Date: | Mon, 10 Mar 2008 15:21:09 +0000 |
| Subject: | Re: Re: [PEPr] Comment on Networking::Net_Nmap | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-49360@lists.php.net to get a copy of this message | ||
> >
> > You need @property(-get, -set) and maybe @method, etc.. There is a set
> of
> > dedicated tags for the magic stuff.
> >
> > Till
>
>
> The extra @property tags are @property-read and @property-write, not
> -get/-set, and I don't think they mean the same thing that is implied by
> -get/-set.
>
> If you're going to skip documenting your private variables altogether,
> along
> with removing explicit get/set methods for them, I'd say use the plain
> @property tags for describing the variables, and maybe include a mention
> of
> "(use magic __get()/__set() for accessing these)".
> --
> CRB
>
Thanks to all. It seems to work as reported below, the mistake I made was
to define @property tags inside the class as doc for the property instead of
doc for the class.
/**
* Service object
* @property int $port The port number where the service is running on.
*/
class Service
{
private $port;
private function __get($key)
{
if(property_exists($this, $key)) {
return $this->$key;
} else {
trigger_error("Trying to get an undefined object: '$key'",
E_USER_ERROR);
}
}
private function __set($key, $value) {
if(property_exists($this, $key)) {
$this->{$key} = $value;
return true;
} else {
trigger_error("Trying to set an undefined object: '$key'",
E_USER_ERROR);
}
}
}