From ee81915a1e845d4b98b6e0101c77d529fb0e07f4 Mon Sep 17 00:00:00 2001 From: Paul Kofmann Date: Mon, 30 Dec 2013 15:14:11 +0100 Subject: [PATCH] Removed redundant code in detachBehaviors() After ensureBehaviors() call $this->_behaviors is an array already. And since detachBehavior() unsets elements in $this->_behaviors, $this->_behaviors turns out to be an empty array after all iterations. --- framework/yii/base/Component.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/framework/yii/base/Component.php b/framework/yii/base/Component.php index 4cea9d2..09b9a97 100644 --- a/framework/yii/base/Component.php +++ b/framework/yii/base/Component.php @@ -543,12 +543,9 @@ class Component extends Object public function detachBehaviors() { $this->ensureBehaviors(); - if ($this->_behaviors !== null) { - foreach ($this->_behaviors as $name => $behavior) { - $this->detachBehavior($name); - } + foreach ($this->_behaviors as $name => $behavior) { + $this->detachBehavior($name); } - $this->_behaviors = []; } /**