yii\base\Component::__get PHP Method

__get() public method

This method will check in the following order and act accordingly: - a property defined by a getter: return the getter result - a property of a behavior: return the behavior property value Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $value = $component->property;.
See also: __set()
public __get ( string $name ) : mixed
$name string the property name
return mixed the property value or the value of a behavior's property
    public function __get($name)
    {
        $getter = 'get' . $name;
        if (method_exists($this, $getter)) {
            // read property, e.g. getName()
            return $this->{$getter}();
        } else {
            // behavior property
            $this->ensureBehaviors();
            foreach ($this->_behaviors as $behavior) {
                if ($behavior->canGetProperty($name)) {
                    return $behavior->{$name};
                }
            }
        }
        if (method_exists($this, 'set' . $name)) {
            throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
        } else {
            throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
        }
    }

Usage Example

 /**
  * Check whether we have a plugin installed with that name previous firing up the call
  * @param string $name
  * @return mixed|void
  */
 public function __get($name)
 {
     if (ArrayHelper::keyExists($name, $this->getInstalledPlugins())) {
         return $this->getPlugin($name);
     }
     return parent::__get($name);
 }
All Usage Examples Of yii\base\Component::__get