yii\base\Object::__unset PHP Method

__unset() public method

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing unset($object->property). Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.
See also: http://php.net/manual/en/function.unset.php
public __unset ( string $name )
$name string the property name
    public function __unset($name)
    {
        $setter = 'set' . $name;
        if (method_exists($this, $setter)) {
            $this->{$setter}(null);
        } elseif (method_exists($this, 'get' . $name)) {
            throw new InvalidCallException('Unsetting read-only property: ' . get_class($this) . '::' . $name);
        }
    }

Usage Example

 /**
  * @inheritdoc
  */
 public function __unset($name)
 {
     if (isset($this->_color[$name])) {
         $this->_color[$name] = null;
     } else {
         parent::__unset($name);
     }
 }