From 22c7cef869cca05b2210fdea268466133e3a5307 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 29 Jul 2021 02:19:01 +0300 Subject: [PATCH] Fix PhpDoc in yii\db\Query (#18752) --- framework/db/Query.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/framework/db/Query.php b/framework/db/Query.php index f85881f..1892c8a 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -145,7 +145,7 @@ class Query extends Component implements QueryInterface, ExpressionInterface /** * Creates a DB command that can be used to execute this query. - * @param Connection $db the database connection used to generate the SQL statement. + * @param Connection|null $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used. * @return Command the created DB command instance. */ @@ -236,7 +236,7 @@ class Query extends Component implements QueryInterface, ExpressionInterface /** * Executes the query and returns all results as an array. - * @param Connection $db the database connection used to generate the SQL statement. + * @param Connection|null $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used. * @return array the query results. If the query results in nothing, an empty array will be returned. */ @@ -273,7 +273,7 @@ class Query extends Component implements QueryInterface, ExpressionInterface /** * Executes the query and returns a single row of result. - * @param Connection $db the database connection used to generate the SQL statement. + * @param Connection|null $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used. * @return array|bool the first row (in terms of an array) of the query result. False is returned if the query * results in nothing. @@ -306,7 +306,7 @@ class Query extends Component implements QueryInterface, ExpressionInterface /** * Executes the query and returns the first column of the result. - * @param Connection $db the database connection used to generate the SQL statement. + * @param Connection|null $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used. * @return array the first column of the query result. An empty array is returned if the query results in nothing. */ @@ -354,9 +354,9 @@ class Query extends Component implements QueryInterface, ExpressionInterface * Returns the number of records. * @param string $q the COUNT expression. Defaults to '*'. * Make sure you properly [quote](guide:db-dao#quoting-table-and-column-names) column names in the expression. - * @param Connection $db the database connection used to generate the SQL statement. + * @param Connection|null $db the database connection used to generate the SQL statement. * If this parameter is not given (or null), the `db` application component will be used. - * @return int|string number of records. The result may be a string depending on the + * @return int|string|null number of records. The result may be a string depending on the * underlying database engine and to support integer values higher than a 32bit PHP integer can handle. */ public function count($q = '*', $db = null) @@ -406,7 +406,7 @@ class Query extends Component implements QueryInterface, ExpressionInterface * Returns the minimum of the specified column values. * @param string $q the column name or expression. * Make sure you properly [quote](guide:db-dao#quoting-table-and-column-names) column names in the expression. - * @param Connection $db the database connection used to generate the SQL statement. + * @param Connection|null $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used. * @return mixed the minimum of the specified column values. */ @@ -419,7 +419,7 @@ class Query extends Component implements QueryInterface, ExpressionInterface * Returns the maximum of the specified column values. * @param string $q the column name or expression. * Make sure you properly [quote](guide:db-dao#quoting-table-and-column-names) column names in the expression. - * @param Connection $db the database connection used to generate the SQL statement. + * @param Connection|null $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used. * @return mixed the maximum of the specified column values. */ @@ -430,7 +430,7 @@ class Query extends Component implements QueryInterface, ExpressionInterface /** * Returns a value indicating whether the query result contains any row of data. - * @param Connection $db the database connection used to generate the SQL statement. + * @param Connection|null $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used. * @return bool whether the query result contains any row of data. */ @@ -450,8 +450,9 @@ class Query extends Component implements QueryInterface, ExpressionInterface * Queries a scalar value by setting [[select]] first. * Restores the value of select to make this query reusable. * @param string|ExpressionInterface $selectExpression - * @param Connection|null $db - * @return bool|string + * @param Connection|null $db the database connection used to execute the query. + * @return bool|string|null + * @throws \Throwable if can't create command */ protected function queryScalar($selectExpression, $db) { @@ -479,7 +480,7 @@ class Query extends Component implements QueryInterface, ExpressionInterface try { $command = $this->createCommand($db); } catch (\Exception $e) { - // throw it later + // throw it later (for PHP < 7.0) } catch (\Throwable $e) { // throw it later }