From 9c7a06b122bed4ffa1c17380df9ddbcb45dd4bb2 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 3 May 2012 03:40:35 +0400 Subject: [PATCH] better comments style, missing @thorws --- framework/base/Component.php | 22 +++++++++++++++------- framework/base/Object.php | 10 +++++++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/framework/base/Component.php b/framework/base/Component.php index edf3321..ac08315 100644 --- a/framework/base/Component.php +++ b/framework/base/Component.php @@ -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) diff --git a/framework/base/Object.php b/framework/base/Object.php index 08d736d..3cd5d12 100644 --- a/framework/base/Object.php +++ b/framework/base/Object.php @@ -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); }