From 846f17017cbbe272fd14aef9fdf7a05ae016e7b9 Mon Sep 17 00:00:00 2001 From: crtlib Date: Sat, 3 Aug 2013 23:10:43 +0200 Subject: [PATCH 1/4] Component::hasProperty() small optimization --- framework/yii/base/Component.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/framework/yii/base/Component.php b/framework/yii/base/Component.php index ffab16f..f123148 100644 --- a/framework/yii/base/Component.php +++ b/framework/yii/base/Component.php @@ -221,18 +221,18 @@ class Component extends Object * - the class has a getter or setter method associated with the specified name * (in this case, property name is case-insensitive); * - the class has a member variable with the specified name (when `$checkVar` is true); - * - an attached behavior has a property of the given name (when `$checkBehavior` is true). + * - an attached behavior has a property of the given name (when `$checkBehaviors` is true). * * @param string $name the property name * @param boolean $checkVar whether to treat member variables as properties - * @param boolean $checkBehavior whether to treat behaviors' properties as properties of this component + * @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component * @return boolean whether the property is defined * @see canGetProperty * @see canSetProperty */ - public function hasProperty($name, $checkVar = true, $checkBehavior = true) + public function hasProperty($name, $checkVar = true, $checkBehaviors = true) { - return $this->canGetProperty($name, $checkVar, $checkBehavior) || $this->canSetProperty($name, $checkVar, $checkBehavior); + return $this->canGetProperty($name, $checkVar, $checkBehaviors) || $this->canSetProperty($name, false, $checkBehavior); } /** @@ -242,7 +242,7 @@ class Component extends Object * - the class has a getter method associated with the specified name * (in this case, property name is case-insensitive); * - the class has a member variable with the specified name (when `$checkVar` is true); - * - an attached behavior has a readable property of the given name (when `$checkBehavior` is true). + * - an attached behavior has a readable property of the given name (when `$checkBehaviors` is true). * * @param string $name the property name * @param boolean $checkVar whether to treat member variables as properties @@ -272,7 +272,7 @@ class Component extends Object * - the class has a setter method associated with the specified name * (in this case, property name is case-insensitive); * - the class has a member variable with the specified name (when `$checkVar` is true); - * - an attached behavior has a writable property of the given name (when `$checkBehavior` is true). + * - an attached behavior has a writable property of the given name (when `$checkBehaviors` is true). * * @param string $name the property name * @param boolean $checkVar whether to treat member variables as properties From bb05ed4f24a5f479deef105747b0f28bfa84600d Mon Sep 17 00:00:00 2001 From: crtlib Date: Sat, 3 Aug 2013 23:13:31 +0200 Subject: [PATCH 2/4] Update Component.php --- framework/yii/base/Component.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/yii/base/Component.php b/framework/yii/base/Component.php index f123148..0cb36ee 100644 --- a/framework/yii/base/Component.php +++ b/framework/yii/base/Component.php @@ -232,7 +232,7 @@ class Component extends Object */ public function hasProperty($name, $checkVar = true, $checkBehaviors = true) { - return $this->canGetProperty($name, $checkVar, $checkBehaviors) || $this->canSetProperty($name, false, $checkBehavior); + return $this->canGetProperty($name, $checkVar, $checkBehaviors) || $this->canSetProperty($name, false, $checkBehaviors); } /** From 004c509ca3c48e6930d0d18ddb6251452b55f74b Mon Sep 17 00:00:00 2001 From: crtlib Date: Sat, 3 Aug 2013 23:42:17 +0200 Subject: [PATCH 3/4] checkVar => checkVars --- framework/yii/base/Component.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/framework/yii/base/Component.php b/framework/yii/base/Component.php index 0cb36ee..5ff8ae4 100644 --- a/framework/yii/base/Component.php +++ b/framework/yii/base/Component.php @@ -220,19 +220,19 @@ class Component extends Object * * - the class has a getter or setter method associated with the specified name * (in this case, property name is case-insensitive); - * - the class has a member variable with the specified name (when `$checkVar` is true); + * - the class has a member variable with the specified name (when `$checkVars` is true); * - an attached behavior has a property of the given name (when `$checkBehaviors` is true). * * @param string $name the property name - * @param boolean $checkVar whether to treat member variables as properties + * @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component * @return boolean whether the property is defined * @see canGetProperty * @see canSetProperty */ - public function hasProperty($name, $checkVar = true, $checkBehaviors = true) + public function hasProperty($name, $checkVars = true, $checkBehaviors = true) { - return $this->canGetProperty($name, $checkVar, $checkBehaviors) || $this->canSetProperty($name, false, $checkBehaviors); + return $this->canGetProperty($name, $checkVars, $checkBehaviors) || $this->canSetProperty($name, false, $checkBehaviors); } /** @@ -241,23 +241,23 @@ class Component extends Object * * - the class has a getter method associated with the specified name * (in this case, property name is case-insensitive); - * - the class has a member variable with the specified name (when `$checkVar` is true); + * - the class has a member variable with the specified name (when `$checkVars` is true); * - an attached behavior has a readable property of the given name (when `$checkBehaviors` is true). * * @param string $name the property name - * @param boolean $checkVar whether to treat member variables as properties + * @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component * @return boolean whether the property can be read * @see canSetProperty */ - public function canGetProperty($name, $checkVar = true, $checkBehaviors = true) + public function canGetProperty($name, $checkVars = true, $checkBehaviors = true) { - if (method_exists($this, 'get' . $name) || $checkVar && property_exists($this, $name)) { + if (method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name)) { return true; } elseif ($checkBehaviors) { $this->ensureBehaviors(); foreach ($this->_behaviors as $behavior) { - if ($behavior->canGetProperty($name, $checkVar)) { + if ($behavior->canGetProperty($name, $checkVars)) { return true; } } @@ -271,23 +271,23 @@ class Component extends Object * * - the class has a setter method associated with the specified name * (in this case, property name is case-insensitive); - * - the class has a member variable with the specified name (when `$checkVar` is true); + * - the class has a member variable with the specified name (when `$checkVars` is true); * - an attached behavior has a writable property of the given name (when `$checkBehaviors` is true). * * @param string $name the property name - * @param boolean $checkVar whether to treat member variables as properties + * @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component * @return boolean whether the property can be written * @see canGetProperty */ - public function canSetProperty($name, $checkVar = true, $checkBehaviors = true) + public function canSetProperty($name, $checkVars = true, $checkBehaviors = true) { - if (method_exists($this, 'set' . $name) || $checkVar && property_exists($this, $name)) { + if (method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name)) { return true; } elseif ($checkBehaviors) { $this->ensureBehaviors(); foreach ($this->_behaviors as $behavior) { - if ($behavior->canSetProperty($name, $checkVar)) { + if ($behavior->canSetProperty($name, $checkVars)) { return true; } } From 80f1fda7404b399d9b18fc6f396621decfc18a2b Mon Sep 17 00:00:00 2001 From: crtlib Date: Sat, 3 Aug 2013 23:43:40 +0200 Subject: [PATCH 4/4] checkVar => checkVars --- framework/yii/base/Object.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/framework/yii/base/Object.php b/framework/yii/base/Object.php index 7724008..50ad9e9 100644 --- a/framework/yii/base/Object.php +++ b/framework/yii/base/Object.php @@ -170,17 +170,17 @@ class Object implements Arrayable * * - the class has a getter or setter method associated with the specified name * (in this case, property name is case-insensitive); - * - the class has a member variable with the specified name (when `$checkVar` is true); + * - the class has a member variable with the specified name (when `$checkVars` is true); * * @param string $name the property name - * @param boolean $checkVar whether to treat member variables as properties + * @param boolean $checkVars whether to treat member variables as properties * @return boolean whether the property is defined * @see canGetProperty * @see canSetProperty */ - public function hasProperty($name, $checkVar = true) + public function hasProperty($name, $checkVars = true) { - return $this->canGetProperty($name, $checkVar) || $this->canSetProperty($name, false); + return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false); } /** @@ -189,16 +189,16 @@ class Object implements Arrayable * * - the class has a getter method associated with the specified name * (in this case, property name is case-insensitive); - * - the class has a member variable with the specified name (when `$checkVar` is true); + * - the class has a member variable with the specified name (when `$checkVars` is true); * * @param string $name the property name - * @param boolean $checkVar whether to treat member variables as properties + * @param boolean $checkVars whether to treat member variables as properties * @return boolean whether the property can be read * @see canSetProperty */ - public function canGetProperty($name, $checkVar = true) + public function canGetProperty($name, $checkVars = true) { - return method_exists($this, 'get' . $name) || $checkVar && property_exists($this, $name); + return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name); } /** @@ -207,16 +207,16 @@ class Object implements Arrayable * * - the class has a setter method associated with the specified name * (in this case, property name is case-insensitive); - * - the class has a member variable with the specified name (when `$checkVar` is true); + * - the class has a member variable with the specified name (when `$checkVars` is true); * * @param string $name the property name - * @param boolean $checkVar whether to treat member variables as properties + * @param boolean $checkVars whether to treat member variables as properties * @return boolean whether the property can be written * @see canGetProperty */ - public function canSetProperty($name, $checkVar = true) + public function canSetProperty($name, $checkVars = true) { - return method_exists($this, 'set' . $name) || $checkVar && property_exists($this, $name); + return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name); } /**