From 55d33d97d8490af4e47eeb32bbdb3d3e8c0af59b Mon Sep 17 00:00:00 2001 From: bscheshirwork Date: Fri, 15 Jan 2016 18:05:26 +0200 Subject: [PATCH] Require guzzle, minor code enhancemants --- composer.json | 3 ++- src/ActiveQuery.php | 6 ++++-- src/ActiveRecord.php | 6 +++--- src/Query.php | 24 +----------------------- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/composer.json b/composer.json index 8989ff2..4141145 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,8 @@ } ], "require": { - "yiisoft/yii2": "~2.0" + "yiisoft/yii2": "~2.0", + "guzzlehttp/guzzle": "6.*" }, "require-dev": { "minii/db": "*@dev", diff --git a/src/ActiveQuery.php b/src/ActiveQuery.php index 9e83ace..4370d70 100644 --- a/src/ActiveQuery.php +++ b/src/ActiveQuery.php @@ -329,7 +329,7 @@ public function one($db = null) $result = $this->createCommand($db)->search(ArrayHelper::merge(['limit' => 1], $this->options)); if (empty($result)) { - return; + return null; } $result = reset($result); @@ -427,7 +427,9 @@ public function getList($as_array = true, $db = null, $options = []) } $result = $models; } - $result = $result ?: []; + if (empty($result)) { + $result = []; + } // return $this->createCommand($db)->getList($options); return $as_array ? ArrayHelper::map($result, 'gl_key', function ($o) { diff --git a/src/ActiveRecord.php b/src/ActiveRecord.php index 9acff7f..b06552b 100644 --- a/src/ActiveRecord.php +++ b/src/ActiveRecord.php @@ -84,7 +84,7 @@ public function isScenarioDefault() public static function get($primaryKey = null, $options = []) { if ($primaryKey === null) { - return; + return null; } $command = static::getDb()->createCommand(); $result = $command->get(static::type(), $primaryKey, $options); @@ -97,7 +97,7 @@ public static function get($primaryKey = null, $options = []) return $model; } - return; + return null; } /** @@ -443,7 +443,7 @@ public function getIsNewRecord() */ public function optimisticLock() { - return; + return null; } /** diff --git a/src/Query.php b/src/Query.php index d75c91c..4a2f1ad 100644 --- a/src/Query.php +++ b/src/Query.php @@ -21,13 +21,7 @@ class Query extends Component implements QueryInterface use QueryTrait; public $index; - public $type; - - public $where; - public $_limit; - public $offset; - public $orderBy; public $select; public $join; @@ -134,7 +128,7 @@ public function scalar($field, $db = null) } } - return; + return null; } public function column($field, $db = null) @@ -255,20 +249,4 @@ public function timeout($timeout) return $this; } - - /** - * @return mixed - */ - public function getLimit() - { - return $this->_limit; - } - - /** - * @param mixed $limit - */ - public function setLimit($limit) - { - $this->_limit = $limit; - } }