Commit 9c7a06b1 by Alexander Makarov

better comments style, missing @thorws

parent 6e592f03
......@@ -47,9 +47,11 @@ class Component extends \yii\base\Object
public function __get($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) { // read property, e.g. getName()
if (method_exists($this, $getter)) {
// read property, e.g. getName()
return $this->$getter();
} else { // behavior property
} else {
// behavior property
$this->ensureBehaviors();
foreach ($this->_b as $behavior) {
if ($behavior->canGetProperty($name)) {
......@@ -91,7 +93,8 @@ class Component extends \yii\base\Object
// as behavior: attach behavior
$name = trim(substr($name, 3));
$this->attachBehavior($name, \Yii::createObject($value));
} else { // behavior property
} else {
// behavior property
$this->ensureBehaviors();
foreach ($this->_b as $behavior) {
if ($behavior->canSetProperty($name)) {
......@@ -122,9 +125,11 @@ class Component extends \yii\base\Object
public function __isset($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) { // property is not null
if (method_exists($this, $getter)) {
// property is not null
return $this->$getter() !== null;
} else { // behavior property
} else {
// behavior property
$this->ensureBehaviors();
foreach ($this->_b as $behavior) {
if ($behavior->canGetProperty($name)) {
......@@ -150,10 +155,12 @@ class Component extends \yii\base\Object
public function __unset($name)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) { // write property
if (method_exists($this, $setter)) {
// write property
$this->$setter(null);
return;
} else { // behavior property
} else {
// behavior property
$this->ensureBehaviors();
foreach ($this->_b as $behavior) {
if ($behavior->canSetProperty($name)) {
......@@ -178,6 +185,7 @@ class Component extends \yii\base\Object
* will be implicitly called when an unknown method is being invoked.
* @param string $name the method name
* @param array $params method parameters
* @throws Exception when calling unknown method
* @return mixed the method return value
*/
public function __call($name, $params)
......
......@@ -82,7 +82,8 @@ class Object
public function __isset($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) { // property is not null
if (method_exists($this, $getter)) {
// property is not null
return $this->$getter() !== null;
} else {
return false;
......@@ -103,7 +104,8 @@ class Object
public function __unset($name)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) { // write property
if (method_exists($this, $setter)) {
// write property
$this->$setter(null);
} elseif (method_exists($this, 'get' . $name)) {
throw new Exception('Unsetting read-only property: ' . get_class($this) . '.' . $name);
......@@ -119,6 +121,7 @@ class Object
* will be implicitly called when an unknown method is being invoked.
* @param string $name the method name
* @param array $params method parameters
* @throws Exception when calling unknown method
* @return mixed the method return value
*/
public function __call($name, $params)
......@@ -267,7 +270,8 @@ class Object
} elseif ($n === 4) {
$object = new $class($args[1], $args[2], $args[3]);
} else {
array_shift($args); // remove $config
// remove $config
array_shift($args);
$r = new \ReflectionClass($class);
$object = $r->newInstanceArgs($args);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment