66
77use Exception as GenericException ;
88use Laminas \Db \Adapter \Driver \AbstractConnection ;
9+ use Laminas \Db \Adapter \Driver \ResultInterface ;
910use Laminas \Db \Adapter \Exception ;
1011use Laminas \Db \Adapter \Exception \InvalidArgumentException ;
12+ use Override ;
1113
1214use function constant ;
1315use function defined ;
@@ -45,20 +47,16 @@ public function __construct($connectionInfo = null)
4547 }
4648 }
4749
48- /**
49- * @return $this Provides a fluent interface
50- */
51- public function setDriver (Mysqli $ driver )
50+ public function setDriver (Mysqli $ driver ): static
5251 {
5352 $ this ->driver = $ driver ;
5453
5554 return $ this ;
5655 }
5756
58- /**
59- * {@inheritDoc}
60- */
61- public function getCurrentSchema ()
57+ /** @inheritDoc */
58+ #[Override]
59+ public function getCurrentSchema (): string |bool
6260 {
6361 if (! $ this ->isConnected ()) {
6462 $ this ->connect ();
@@ -82,10 +80,9 @@ public function setResource(\mysqli $resource)
8280 return $ this ;
8381 }
8482
85- /**
86- * {@inheritDoc}
87- */
88- public function connect ()
83+ /** @inheritDoc */
84+ #[Override]
85+ public function connect (): static
8986 {
9087 if ($ this ->resource instanceof \mysqli) {
9188 return $ this ;
@@ -180,29 +177,26 @@ public function connect()
180177 return $ this ;
181178 }
182179
183- /**
184- * {@inheritDoc}
185- */
186- public function isConnected ()
180+ /** @inheritDoc */
181+ public function isConnected (): bool
187182 {
188183 return $ this ->resource instanceof \mysqli;
189184 }
190185
191- /**
192- * {@inheritDoc}
193- */
194- public function disconnect ()
186+ /** @inheritDoc */
187+ #[Override]
188+ public function disconnect (): static
195189 {
196190 if ($ this ->resource instanceof \mysqli) {
197191 $ this ->resource ->close ();
198192 }
199193 $ this ->resource = null ;
194+ return $ this ;
200195 }
201196
202- /**
203- * {@inheritDoc}
204- */
205- public function beginTransaction ()
197+ /** @inheritDoc */
198+ #[Override]
199+ public function beginTransaction (): static
206200 {
207201 if (! $ this ->isConnected ()) {
208202 $ this ->connect ();
@@ -214,10 +208,9 @@ public function beginTransaction()
214208 return $ this ;
215209 }
216210
217- /**
218- * {@inheritDoc}
219- */
220- public function commit ()
211+ /** @inheritDoc */
212+ #[Override]
213+ public function commit (): static
221214 {
222215 if (! $ this ->isConnected ()) {
223216 $ this ->connect ();
@@ -230,10 +223,9 @@ public function commit()
230223 return $ this ;
231224 }
232225
233- /**
234- * {@inheritDoc}
235- */
236- public function rollback ()
226+ /** @inheritDoc */
227+ #[Override]
228+ public function rollback (): static
237229 {
238230 if (! $ this ->isConnected ()) {
239231 throw new Exception \RuntimeException ('Must be connected before you can rollback. ' );
@@ -251,11 +243,12 @@ public function rollback()
251243 }
252244
253245 /**
254- * { @inheritDoc}
246+ * @inheritDoc
255247 *
256248 * @throws Exception\InvalidQueryException
257249 */
258- public function execute ($ sql )
250+ #[Override]
251+ public function execute ($ sql ): ResultInterface
259252 {
260253 if (! $ this ->isConnected ()) {
261254 $ this ->connect ();
@@ -279,17 +272,18 @@ public function execute($sql)
279272 return $ this ->driver ->createResult ($ resultResource === true ? $ this ->resource : $ resultResource );
280273 }
281274
282- /**
283- * {@inheritDoc}
284- */
285- public function getLastGeneratedValue ($ name = null )
275+ /** @inheritDoc */
276+ #[Override]
277+ public function getLastGeneratedValue ($ name = null ): string |int |bool |null
286278 {
287279 return $ this ->resource ->insert_id ;
288280 }
289281
290282 /**
291283 * Create a new mysqli resource
292284 *
285+ * todo: why do we have this random method here?
286+ *
293287 * @return \mysqli
294288 */
295289 protected function createResource ()
0 commit comments