State::__set()

Sets a state via property access.

Table of Contents
  1. Description
  2. Example

Description

State::__set(string $key, mixed $value): void;

This method will be called when you try to set a property that doesn’t exist in the class. For this class, this method will execute State::set() internally.

Example

$state = new State(['test' => 1]);

$state->test = 2;

echo $state->test; // Returns `2`

Method name will be normalized by function p2f(). So, when you try to set $state->dateFormat property for example, internally you are trying to set a state with name date-format. This is also the same when you try to set $state->{'date-format'} property. No normalization will be performed in this case.

State::__set()

Sets a state via property access.