Skip to content

Tag reference

@property-write

The @property-write tag declares a magic property that can only be written, never read back: __set is expected to handle it, but __get should reject it (or simply doesn’t exist). It is the mirror image of @property-read — useful for write-only concerns such as a setter that stores a hashed or otherwise transformed value that the object never exposes in its original form.

Grammar

"@phan-property-write" <Type> <Variable> [ <Description> ]
"@phpstan-property-write" <Type> <Variable> [ <Description> ]
"@property-write" <Type> <Variable> [ <Description> ]
"@psalm-property-write" <Type> <Variable> [ <Description> ]

Examples

A setter with no corresponding getter.
/**
* @property-write string $password
*/
class Account
{
public function __set(string $name, mixed $value): void {
/* ... */
}
}
A write-only property with a description.
/**
* @property-write LoggerInterface $logger Replaces the logger used
* internally.
*/
class Service {}

Names by platform

phan
@phan-property-write
phpstan
@phpstan-property-write
psalm
@psalm-property-write
standard
@property-write

Parsing a @property-write tag produces a TypedVariableTag instance exposing:

  • $type — the documented TypeNode.
  • $variable — the property’s name, without the leading $.
final class PropertyWriteTag extends MagicPropertyTag
{
// Same shape as PropertyReadTag: inherits `$type`
// and `string $variable` from MagicPropertyTag;
// adds nothing of its own.
}

Use @property instead when both directions are supported, or @property-read for the mirror case of a read-only property.

Defined by the same PSR-19 §5.11 section as @property, and phpDocumentor’s own @property-write reference.