11<?php namespace Tests \Support \Database ;
22
3+ use CodeIgniter \CodeIgniter ;
34use CodeIgniter \Database \BaseConnection ;
45
56class MockConnection extends BaseConnection
@@ -21,7 +22,23 @@ public function shouldReturn(string $method, $return)
2122
2223 //--------------------------------------------------------------------
2324
24- public function query (string $ sql , $ binds = null , bool $ setEscapeFlags = true , $ queryClass = 'CodeIgniter \\Database \\Query ' )
25+ /**
26+ * Orchestrates a query against the database. Queries must use
27+ * Database\Statement objects to store the query and build it.
28+ * This method works with the cache.
29+ *
30+ * Should automatically handle different connections for read/write
31+ * queries if needed.
32+ *
33+ * @param string $sql
34+ * @param mixed ...$binds
35+ * @param boolean $setEscapeFlags
36+ * @param string $queryClass
37+ *
38+ * @return \CodeIgniter\Database\BaseResult|\CodeIgniter\Database\Query|false
39+ */
40+
41+ public function query (string $ sql , $ binds = null , bool $ setEscapeFlags = true , string $ queryClass = 'CodeIgniter \\Database \\Query ' )
2542 {
2643 $ queryClass = str_replace ('Connection ' , 'Query ' , get_class ($ this ));
2744
@@ -60,9 +77,11 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, $
6077 /**
6178 * Connect to the database.
6279 *
80+ * @param boolean $persistent
81+ *
6382 * @return mixed
6483 */
65- public function connect ($ persistent = false )
84+ public function connect (bool $ persistent = false )
6685 {
6786 $ return = $ this ->returnValues ['connect ' ] ?? true ;
6887
@@ -82,9 +101,9 @@ public function connect($persistent = false)
82101 * Keep or establish the connection if no queries have been sent for
83102 * a length of time exceeding the server's idle timeout.
84103 *
85- * @return mixed
104+ * @return boolean
86105 */
87- public function reconnect ()
106+ public function reconnect (): bool
88107 {
89108 return true ;
90109 }
@@ -110,23 +129,23 @@ public function setDatabase(string $databaseName)
110129 /**
111130 * Returns a string containing the version of the database being used.
112131 *
113- * @return mixed
132+ * @return string
114133 */
115- public function getVersion ()
134+ public function getVersion (): string
116135 {
117- return \ CodeIgniter \ CodeIgniter::CI_VERSION ;
136+ return CodeIgniter::CI_VERSION ;
118137 }
119138
120139 //--------------------------------------------------------------------
121140
122141 /**
123142 * Executes the query against the database.
124143 *
125- * @param $sql
144+ * @param string $sql
126145 *
127146 * @return mixed
128147 */
129- protected function execute ($ sql )
148+ protected function execute (string $ sql )
130149 {
131150 return $ this ->returnValues ['execute ' ];
132151 }
@@ -136,7 +155,7 @@ protected function execute($sql)
136155 /**
137156 * Returns the total number of rows affected by this query.
138157 *
139- * @return mixed
158+ * @return int
140159 */
141160 public function affectedRows (): int
142161 {
@@ -154,7 +173,7 @@ public function affectedRows(): int
154173 *
155174 * @return array
156175 */
157- public function error ()
176+ public function error (): array
158177 {
159178 return [
160179 'code ' => null ,
@@ -169,7 +188,7 @@ public function error()
169188 *
170189 * @return integer
171190 */
172- public function insertID ()
191+ public function insertID (): int
173192 {
174193 return $ this ->connID ->insert_id ;
175194 }
@@ -183,7 +202,7 @@ public function insertID()
183202 *
184203 * @return string
185204 */
186- protected function _listTables ($ constrainByPrefix = false ): string
205+ protected function _listTables (bool $ constrainByPrefix = false ): string
187206 {
188207 return '' ;
189208 }
0 commit comments