diff --git a/extensions/mutex/yii/mutex/Mutex.php b/extensions/mutex/yii/mutex/Mutex.php index 8f0a560..db14ce8 100644 --- a/extensions/mutex/yii/mutex/Mutex.php +++ b/extensions/mutex/yii/mutex/Mutex.php @@ -34,11 +34,10 @@ abstract class Mutex extends Component public function init() { if ($this->autoRelease) { - $mutex = $this; $locks = &$this->_locks; - register_shutdown_function(function () use ($mutex, &$locks) { + register_shutdown_function(function () use ($this, &$locks) { foreach ($locks as $lock) { - $mutex->release($lock); + $this->release($lock); } }); } diff --git a/framework/yii/base/ErrorHandler.php b/framework/yii/base/ErrorHandler.php index 40f5c37..37e4a85 100644 --- a/framework/yii/base/ErrorHandler.php +++ b/framework/yii/base/ErrorHandler.php @@ -175,10 +175,9 @@ class ErrorHandler extends Component $html = rtrim($html, '\\'); } elseif (strpos($code, '()') !== false) { // method/function call - $self = $this; - $html = preg_replace_callback('/^(.*)\(\)$/', function ($matches) use ($self) { - return '' . - $self->htmlEncode($matches[1]) . '()'; + $html = preg_replace_callback('/^(.*)\(\)$/', function ($matches) use ($this) { + return '' . + $this->htmlEncode($matches[1]) . '()'; }, $code); } return $html; diff --git a/framework/yii/db/Connection.php b/framework/yii/db/Connection.php index 69bf6a5..d3058cf 100644 --- a/framework/yii/db/Connection.php +++ b/framework/yii/db/Connection.php @@ -508,13 +508,12 @@ class Connection extends Component */ public function quoteSql($sql) { - $db = $this; return preg_replace_callback('/(\\{\\{(%?[\w\-\. ]+%?)\\}\\}|\\[\\[([\w\-\. ]+)\\]\\])/', - function ($matches) use ($db) { + function ($matches) use ($this) { if (isset($matches[3])) { - return $db->quoteColumnName($matches[3]); + return $this->quoteColumnName($matches[3]); } else { - return str_replace('%', $db->tablePrefix, $db->quoteTableName($matches[2])); + return str_replace('%', $this->tablePrefix, $this->quoteTableName($matches[2])); } }, $sql); } diff --git a/framework/yii/debug/Module.php b/framework/yii/debug/Module.php index 9550b57..a9929c4 100644 --- a/framework/yii/debug/Module.php +++ b/framework/yii/debug/Module.php @@ -57,9 +57,8 @@ class Module extends \yii\base\Module $this->dataPath = Yii::getAlias($this->dataPath); $this->logTarget = Yii::$app->getLog()->targets['debug'] = new LogTarget($this); // do not initialize view component before application is ready (needed when debug in preload) - $module = $this; - Yii::$app->on(Application::EVENT_BEFORE_ACTION, function() use ($module) { - Yii::$app->getView()->on(View::EVENT_END_BODY, array($module, 'renderToolbar')); + Yii::$app->on(Application::EVENT_BEFORE_ACTION, function() use ($this) { + Yii::$app->getView()->on(View::EVENT_END_BODY, array($this, 'renderToolbar')); }); foreach (array_merge($this->corePanels(), $this->panels) as $id => $config) { diff --git a/framework/yii/grid/ActionColumn.php b/framework/yii/grid/ActionColumn.php index 6a4ed9f..aae59ae 100644 --- a/framework/yii/grid/ActionColumn.php +++ b/framework/yii/grid/ActionColumn.php @@ -88,11 +88,10 @@ class ActionColumn extends Column */ protected function renderDataCellContent($model, $index) { - $column = $this; - return preg_replace_callback('/\\{(\w+)\\}/', function ($matches) use ($model, $column) { + return preg_replace_callback('/\\{(\w+)\\}/', function ($matches) use ($this, $model) { $name = $matches[1]; - if (isset($column->buttons[$name])) { - return call_user_func($column->buttons[$name], $model, $column); + if (isset($this->buttons[$name])) { + return call_user_func($this->buttons[$name], $model, $this); } else { return ''; } diff --git a/framework/yii/widgets/BaseListView.php b/framework/yii/widgets/BaseListView.php index d90ac89..e292f38 100644 --- a/framework/yii/widgets/BaseListView.php +++ b/framework/yii/widgets/BaseListView.php @@ -92,9 +92,8 @@ abstract class BaseListView extends Widget public function run() { if ($this->dataProvider->getCount() > 0 || $this->empty === false) { - $widget = $this; - $content = preg_replace_callback("/{\\w+}/", function ($matches) use ($widget) { - $content = $widget->renderSection($matches[0]); + $content = preg_replace_callback("/{\\w+}/", function ($matches) use ($this) { + $content = $this->renderSection($matches[0]); return $content === false ? $matches[0] : $content; }, $this->layout); } else {