yii\base\Component::__unset PHP Method

__unset() public method

This method will check in the following order and act accordingly: - a property defined by a setter: set the property value to be null - a property of a behavior: set the property value to be null Do not call this method directly as it is a PHP magic method that will be implicitly called when executing unset($component->property).
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);
            return;
        } else {
            // behavior property
            $this->ensureBehaviors();
            foreach ($this->_behaviors as $behavior) {
                if ($behavior->canSetProperty($name)) {
                    $behavior->{$name} = null;
                    return;
                }
            }
        }
        throw new InvalidCallException('Unsetting an unknown or read-only property: ' . get_class($this) . '::' . $name);
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  */
 public function __unset($name)
 {
     if (property_exists($this->obj, $name)) {
         $this->obj->{$name} = null;
         return;
     }
     parent::__unset($name);
 }
All Usage Examples Of yii\base\Component::__unset