From 6100849e2fee8697748ef207194018dd5ddccd24 Mon Sep 17 00:00:00 2001 From: Angel Guevara Date: Tue, 11 Oct 2016 08:00:45 -0500 Subject: [PATCH] Documentation ActiveQueryInterface::one() (#12682) * Documentation ActiveQueryInterface::one() Currently there is an issue when using `BaseActiveRecord::findOne()` because it uses the return type for `ActiveQueryInterface::one()` which is inherited from `QueryInterface::one()` which returns `array|false` https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/db/BaseActiveRecord.php?selectedAuthors%5B0%5D=angeldelcaos%40gmail.com&orderField=path&order=asc&honorSelectedPaths=0 * null -> `null` --- framework/db/ActiveQueryInterface.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/framework/db/ActiveQueryInterface.php b/framework/db/ActiveQueryInterface.php index d237ddb17a..4f8341a6d0 100644 --- a/framework/db/ActiveQueryInterface.php +++ b/framework/db/ActiveQueryInterface.php @@ -28,6 +28,16 @@ interface ActiveQueryInterface extends QueryInterface * @return $this the query object itself */ public function asArray($value = true); + + /** + * Executes query and returns a single row of result. + * @param Connection $db the DB connection used to create the DB command. + * If `null`, the DB connection returned by [[modelClass]] will be used. + * @return ActiveRecordInterface|array|null a single row of query result. Depending on the setting of [[asArray]], + * the query result may be either an array or an ActiveRecord object. `null` will be returned + * if the query results in nothing. + */ + public function one($db = null); /** * Sets the [[indexBy]] property.