yii\base\Object::__set PHP Method

__set() public method

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $object->property = $value;.
See also: __get()
public __set ( string $name, mixed $value )
$name string the property name or the event name
$value mixed the property value
    public function __set($name, $value)
    {
        $setter = 'set' . $name;
        if (method_exists($this, $setter)) {
            $this->{$setter}($value);
        } elseif (method_exists($this, 'get' . $name)) {
            throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
        } else {
            throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
        }
    }

Usage Example

Example #1
0
 /**
  * @param string $name
  * @param mixed $value
  */
 public function __set($name, $value)
 {
     try {
         parent::__set($name, $value);
     } catch (UnknownPropertyException $e) {
     }
 }
All Usage Examples Of yii\base\Object::__set