22
33namespace Doctrine \DBAL ;
44
5+ use Doctrine \DBAL \Driver \ResultStatement ;
56use Doctrine \DBAL \Driver \ServerInfoAwareConnection ;
7+ use Doctrine \DBAL \Driver \Statement as DriverStatement ;
68use Doctrine \DBAL \Exception \InvalidArgumentException ;
79use Closure ;
810use Exception ;
1719use Throwable ;
1820use function array_key_exists ;
1921use function array_merge ;
20- use function func_get_args ;
2122use function implode ;
2223use function is_int ;
2324use function is_string ;
@@ -856,18 +857,16 @@ public function fetchAll($sql, array $params = [], $types = [])
856857 /**
857858 * Prepares an SQL statement.
858859 *
859- * @param string $statement The SQL statement to prepare.
860+ * @param string $sql The SQL statement to prepare.
860861 *
861- * @return \Doctrine\DBAL\Statement The prepared statement.
862- *
863- * @throws \Doctrine\DBAL\DBALException
862+ * @throws DBALException
864863 */
865- public function prepare ($ statement )
864+ public function prepare (string $ sql ) : DriverStatement
866865 {
867866 try {
868- $ stmt = new Statement ($ statement , $ this );
867+ $ stmt = new Statement ($ sql , $ this );
869868 } catch (Exception $ ex ) {
870- throw DBALException::driverExceptionDuringQuery ($ this ->_driver , $ ex , $ statement );
869+ throw DBALException::driverExceptionDuringQuery ($ this ->_driver , $ ex , $ sql );
871870 }
872871
873872 $ stmt ->setFetchMode ($ this ->defaultFetchMode );
@@ -881,16 +880,14 @@ public function prepare($statement)
881880 * If the query is parametrized, a prepared statement is used.
882881 * If an SQLLogger is configured, the execution is logged.
883882 *
884- * @param string $query The SQL query to execute.
885- * @param array $params The parameters to bind to the query, if any.
886- * @param array $types The types the previous parameters are in.
887- * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp The query cache profile, optional.
888- *
889- * @return \Doctrine\DBAL\Driver\Statement The executed statement.
883+ * @param string $query The SQL query to execute.
884+ * @param mixed[] $params The parameters to bind to the query, if any.
885+ * @param (int|string|Type)[] $types The types the previous parameters are in.
886+ * @param QueryCacheProfile|null $qcp The query cache profile, optional.
890887 *
891- * @throws \Doctrine\DBAL\ DBALException
888+ * @throws DBALException
892889 */
893- public function executeQuery ($ query , array $ params = [], $ types = [], QueryCacheProfile $ qcp = null )
890+ public function executeQuery (string $ query , array $ params = [], $ types = [], ? QueryCacheProfile $ qcp = null ) : ResultStatement
894891 {
895892 if ($ qcp !== null ) {
896893 return $ this ->executeCacheQuery ($ query , $ params , $ types , $ qcp );
@@ -929,16 +926,14 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
929926 /**
930927 * Executes a caching query.
931928 *
932- * @param string $query The SQL query to execute.
933- * @param array $params The parameters to bind to the query, if any.
934- * @param array $types The types the previous parameters are in.
935- * @param \Doctrine\DBAL\Cache\QueryCacheProfile $qcp The query cache profile.
936- *
937- * @return \Doctrine\DBAL\Driver\ResultStatement
929+ * @param string $query The SQL query to execute.
930+ * @param mixed[] $params The parameters to bind to the query, if any.
931+ * @param (int|string)|Type[] $types The types the previous parameters are in.
932+ * @param QueryCacheProfile $qcp The query cache profile.
938933 *
939- * @throws \Doctrine\DBAL\Cache\CacheException
934+ * @throws DBALException
940935 */
941- public function executeCacheQuery ($ query , $ params , $ types , QueryCacheProfile $ qcp )
936+ public function executeCacheQuery ($ query , $ params , $ types , QueryCacheProfile $ qcp ) : ResultStatement
942937 {
943938 $ resultCache = $ qcp ->getResultCacheDriver () ?: $ this ->_config ->getResultCacheImpl ();
944939 if ( ! $ resultCache ) {
@@ -995,7 +990,7 @@ public function project($query, array $params, Closure $function)
995990 /**
996991 * {@inheritDoc}
997992 */
998- public function query (string $ sql )
993+ public function query (string $ sql ) : ResultStatement
999994 {
1000995 $ this ->connect ();
1001996
@@ -1021,15 +1016,13 @@ public function query(string $sql)
10211016 *
10221017 * This method supports PDO binding types as well as DBAL mapping types.
10231018 *
1024- * @param string $query The SQL query.
1025- * @param array $params The query parameters.
1026- * @param array $types The parameter types.
1027- *
1028- * @return int The number of affected rows.
1019+ * @param string $query The SQL query.
1020+ * @param mixed[] $params The query parameters.
1021+ * @param (int|string|Type)[] $types The parameter types.
10291022 *
1030- * @throws \Doctrine\DBAL\ DBALException
1023+ * @throws DBALException
10311024 */
1032- public function executeUpdate ($ query , array $ params = [], array $ types = [])
1025+ public function executeUpdate (string $ query , array $ params = [], array $ types = []) : int
10331026 {
10341027 $ this ->connect ();
10351028
@@ -1061,15 +1054,9 @@ public function executeUpdate($query, array $params = [], array $types = [])
10611054 }
10621055
10631056 /**
1064- * Executes an SQL statement and return the number of affected rows.
1065- *
1066- * @param string $statement
1067- *
1068- * @return int The number of affected rows.
1069- *
1070- * @throws \Doctrine\DBAL\DBALException
1057+ * {@inheritDoc}
10711058 */
1072- public function exec ($ statement )
1059+ public function exec (string $ statement ) : int
10731060 {
10741061 $ this ->connect ();
10751062
@@ -1473,16 +1460,11 @@ public function convertToPHPValue($value, $type)
14731460 * Binds a set of parameters, some or all of which are typed with a PDO binding type
14741461 * or DBAL mapping type, to a given statement.
14751462 *
1476- * @param \Doctrine\DBAL\Driver\Statement $stmt The statement to bind the values to.
1477- * @param array $params The map/list of named/positional parameters.
1478- * @param array $types The parameter types (PDO binding types or DBAL mapping types).
1479- *
1480- * @return void
1481- *
1482- * @internal Duck-typing used on the $stmt parameter to support driver statements as well as
1483- * raw PDOStatement instances.
1463+ * @param DriverStatement $stmt The statement to bind the values to.
1464+ * @param mixed[] $params The map/list of named/positional parameters.
1465+ * @param (int|string|Type)[] $types The parameter types.
14841466 */
1485- private function _bindTypedValues ($ stmt , array $ params , array $ types )
1467+ private function _bindTypedValues (DriverStatement $ stmt , array $ params , array $ types ) : void
14861468 {
14871469 // Check whether parameters are positional or named. Mixing is not allowed, just like in PDO.
14881470 if (is_int (key ($ params ))) {
0 commit comments