Since: 8.0

class Immutable (View source)

Mark a property (or all class properties in the case of a class) as immutable.

By default, an IDE highlights write accesses on such properties if they are located outside a constructor (this scope is customizable, see below).

You can provide a custom allowed write scope by using the following values:

  • Immutable::CONSTRUCTOR_WRITE_SCOPE: write is allowed only in containing class constructor (default choice)
  • Immutable::PRIVATE_WRITE_SCOPE: write is allowed only in places where the property would be accessible if it had 'private' visibility modifier
  • Immutable::PROTECTED_WRITE_SCOPE: write is allowed only in places where the property would be accessible if it had 'protected' visibility modifier

Constants

CONSTRUCTOR_WRITE_SCOPE

PRIVATE_WRITE_SCOPE

PROTECTED_WRITE_SCOPE

Methods

__construct($allowedWriteScope = self::CONSTRUCTOR_WRITE_SCOPE)

No description

Details

__construct($allowedWriteScope = self::CONSTRUCTOR_WRITE_SCOPE)

No description

Parameters

$allowedWriteScope