¿Cómo explicar los atributos PHPDoc de `@ property-read` y` @ property-write`?

Dado que phpDoc manual, I cannot find explanation about that

  • @property-read
  • @property-write

but only of @property.

¿Qué hacen?

preguntado el 08 de noviembre de 11 a las 09:11

2 Respuestas

Aquí hay una buena explicación on magic properties.

Básicamente, @property-write is interpreted - as the name suggests - as a write-only property. The code completion in Eclipse, for example, makes use of this. If your magic property foo is declared "write-only", it wouldn't show up in code completion, when you type $a = $this->f.

respondido 08 nov., 11:13

yes i already read that page, but it still not clear for me what is @property-read y @property-write - GusDeCooL

The @property tag is what's documented in the phpDocumentor manual. This tag is used only in a class docblock to document a "magic" property/variable, i.e. one that is not defined in the code, and therefore can't be "docblock'd".

Now, when you want to highlight that a particular "magic variable" is read-only (not writable), you'd use @property-read. If you have a "magic variable" that is write-only (not readable), you'd use @property-write. Granted, I have trouble imagining write-only variables that can't be read, but since it's technically possible to do it, @property-write is available for you to document it.

These two "subtags" of @property are explained farther down on the @property page that you linked to above.

respondido 09 nov., 11:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.