@@ -422,12 +422,14 @@ public function initialize()
422
422
* @param boolean $persistent
423
423
* @return mixed
424
424
*/
425
- abstract public function connect ($ persistent = false );
425
+ abstract public function connect (bool $ persistent = false );
426
426
427
427
//--------------------------------------------------------------------
428
428
429
429
/**
430
430
* Close the database connection.
431
+ *
432
+ * @return void
431
433
*/
432
434
public function close ()
433
435
{
@@ -526,9 +528,9 @@ public function getError()
526
528
/**
527
529
* The name of the platform in use (MySQLi, mssql, etc)
528
530
*
529
- * @return mixed
531
+ * @return string
530
532
*/
531
- public function getPlatform ()
533
+ public function getPlatform (): string
532
534
{
533
535
return $ this ->DBDriver ;
534
536
}
@@ -538,9 +540,9 @@ public function getPlatform()
538
540
/**
539
541
* Returns a string containing the version of the database being used.
540
542
*
541
- * @return mixed
543
+ * @return string
542
544
*/
543
- abstract public function getVersion ();
545
+ abstract public function getVersion (): string ;
544
546
545
547
//--------------------------------------------------------------------
546
548
@@ -586,7 +588,7 @@ public function addTableAlias(string $table)
586
588
*
587
589
* @return mixed
588
590
*/
589
- abstract protected function execute ($ sql );
591
+ abstract protected function execute (string $ sql );
590
592
591
593
//--------------------------------------------------------------------
592
594
@@ -599,13 +601,13 @@ abstract protected function execute($sql);
599
601
* queries if needed.
600
602
*
601
603
* @param string $sql
602
- * @param array ...$binds
604
+ * @param mixed ...$binds
603
605
* @param boolean $setEscapeFlags
604
606
* @param string $queryClass
605
607
*
606
608
* @return BaseResult|Query|false
607
609
*/
608
- public function query (string $ sql , $ binds = null , bool $ setEscapeFlags = true , $ queryClass = 'CodeIgniter \\Database \\Query ' )
610
+ public function query (string $ sql , $ binds = null , bool $ setEscapeFlags = true , string $ queryClass = 'CodeIgniter \\Database \\Query ' )
609
611
{
610
612
if (empty ($ this ->connID ))
611
613
{
@@ -713,6 +715,8 @@ public function simpleQuery(string $sql)
713
715
* Disable Transactions
714
716
*
715
717
* This permits transactions to be disabled at run-time.
718
+ *
719
+ * @return void
716
720
*/
717
721
public function transOff ()
718
722
{
@@ -750,7 +754,7 @@ public function transStrict(bool $mode = true)
750
754
* @param boolean $test_mode = FALSE
751
755
* @return boolean
752
756
*/
753
- public function transStart ($ test_mode = false )
757
+ public function transStart (bool $ test_mode = false ): bool
754
758
{
755
759
if (! $ this ->transEnabled )
756
760
{
@@ -767,7 +771,7 @@ public function transStart($test_mode = false)
767
771
*
768
772
* @return boolean
769
773
*/
770
- public function transComplete ()
774
+ public function transComplete (): bool
771
775
{
772
776
if (! $ this ->transEnabled )
773
777
{
@@ -924,7 +928,7 @@ abstract protected function _transRollback(): bool;
924
928
/**
925
929
* Returns an instance of the query builder for this connection.
926
930
*
927
- * @param string $tableName
931
+ * @param string|array $tableName
928
932
*
929
933
* @return BaseBuilder
930
934
* @throws DatabaseException
@@ -1008,7 +1012,7 @@ public function getLastQuery()
1008
1012
*
1009
1013
* @return string
1010
1014
*/
1011
- public function showLastQuery ()
1015
+ public function showLastQuery (): string
1012
1016
{
1013
1017
return (string ) $ this ->lastQuery ;
1014
1018
}
@@ -1023,7 +1027,7 @@ public function showLastQuery()
1023
1027
*
1024
1028
* @return float
1025
1029
*/
1026
- public function getConnectStart ()
1030
+ public function getConnectStart (): float
1027
1031
{
1028
1032
return $ this ->connectTime ;
1029
1033
}
@@ -1038,9 +1042,9 @@ public function getConnectStart()
1038
1042
*
1039
1043
* @param integer $decimals
1040
1044
*
1041
- * @return mixed
1045
+ * @return string
1042
1046
*/
1043
- public function getConnectDuration ($ decimals = 6 )
1047
+ public function getConnectDuration (int $ decimals = 6 ): string
1044
1048
{
1045
1049
return number_format ($ this ->connectDuration , $ decimals );
1046
1050
}
@@ -1067,14 +1071,14 @@ public function getConnectDuration($decimals = 6)
1067
1071
* insert the table prefix (if it exists) in the proper position, and escape only
1068
1072
* the correct identifiers.
1069
1073
*
1070
- * @param string|array
1071
- * @param boolean
1072
- * @param mixed
1073
- * @param boolean
1074
+ * @param string|array $item
1075
+ * @param boolean $prefixSingle
1076
+ * @param boolean $protectIdentifiers
1077
+ * @param boolean $fieldExists
1074
1078
*
1075
1079
* @return string|array
1076
1080
*/
1077
- public function protectIdentifiers ($ item , $ prefixSingle = false , $ protectIdentifiers = null , $ fieldExists = true )
1081
+ public function protectIdentifiers ($ item , bool $ prefixSingle = false , bool $ protectIdentifiers = null , bool $ fieldExists = true )
1078
1082
{
1079
1083
if (! is_bool ($ protectIdentifiers ))
1080
1084
{
@@ -1313,7 +1317,7 @@ public function escapeIdentifiers($item)
1313
1317
* @return string
1314
1318
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
1315
1319
*/
1316
- public function prefixTable ($ table = '' )
1320
+ public function prefixTable (string $ table = '' ): string
1317
1321
{
1318
1322
if ($ table === '' )
1319
1323
{
@@ -1334,7 +1338,7 @@ public function prefixTable($table = '')
1334
1338
*
1335
1339
* @return string
1336
1340
*/
1337
- public function setPrefix ($ prefix = '' )
1341
+ public function setPrefix (string $ prefix = '' ): string
1338
1342
{
1339
1343
return $ this ->DBPrefix = $ prefix ;
1340
1344
}
@@ -1356,7 +1360,7 @@ abstract public function affectedRows(): int;
1356
1360
* Escapes data based on type.
1357
1361
* Sets boolean and null types
1358
1362
*
1359
- * @param $str
1363
+ * @param mixed $str
1360
1364
*
1361
1365
* @return mixed
1362
1366
*/
@@ -1395,9 +1399,9 @@ public function escape($str)
1395
1399
*
1396
1400
* @param string|string[] $str Input string
1397
1401
* @param boolean $like Whether or not the string will be used in a LIKE condition
1398
- * @return string
1402
+ * @return string|string[]
1399
1403
*/
1400
- public function escapeString ($ str , $ like = false )
1404
+ public function escapeString ($ str , bool $ like = false )
1401
1405
{
1402
1406
if (is_array ($ str ))
1403
1407
{
@@ -1473,7 +1477,7 @@ protected function _escapeString(string $str): string
1473
1477
* @return boolean
1474
1478
* @throws DatabaseException
1475
1479
*/
1476
- public function callFunction (string $ functionName , ...$ params )
1480
+ public function callFunction (string $ functionName , ...$ params ): bool
1477
1481
{
1478
1482
$ driver = ($ this ->DBDriver === 'postgre ' ? 'pg ' : strtolower ($ this ->DBDriver )) . '_ ' ;
1479
1483
@@ -1507,7 +1511,7 @@ public function callFunction(string $functionName, ...$params)
1507
1511
* @return boolean|array
1508
1512
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
1509
1513
*/
1510
- public function listTables ($ constrain_by_prefix = false )
1514
+ public function listTables (bool $ constrain_by_prefix = false )
1511
1515
{
1512
1516
// Is there a cached result?
1513
1517
if (isset ($ this ->dataCache ['table_names ' ]) && $ this ->dataCache ['table_names ' ])
@@ -1566,7 +1570,7 @@ public function listTables($constrain_by_prefix = false)
1566
1570
* @param string $table_name
1567
1571
* @return boolean
1568
1572
*/
1569
- public function tableExists ($ table_name )
1573
+ public function tableExists (string $ table_name ): bool
1570
1574
{
1571
1575
return in_array ($ this ->protectIdentifiers ($ table_name , true , false , false ), $ this ->listTables ());
1572
1576
}
@@ -1581,7 +1585,7 @@ public function tableExists($table_name)
1581
1585
* @return array|false
1582
1586
* @throws DatabaseException
1583
1587
*/
1584
- public function getFieldNames ($ table )
1588
+ public function getFieldNames (string $ table )
1585
1589
{
1586
1590
// Is there a cached result?
1587
1591
if (isset ($ this ->dataCache ['field_names ' ][$ table ]))
@@ -1637,11 +1641,11 @@ public function getFieldNames($table)
1637
1641
/**
1638
1642
* Determine if a particular field exists
1639
1643
*
1640
- * @param string
1641
- * @param string
1644
+ * @param string $fieldName
1645
+ * @param string $tableName
1642
1646
* @return boolean
1643
1647
*/
1644
- public function fieldExists ($ fieldName , $ tableName )
1648
+ public function fieldExists (string $ fieldName , string $ tableName ): bool
1645
1649
{
1646
1650
return in_array ($ fieldName , $ this ->getFieldNames ($ tableName ));
1647
1651
}
@@ -1735,7 +1739,7 @@ public function resetDataCache()
1735
1739
*
1736
1740
* @return array
1737
1741
*/
1738
- abstract public function error ();
1742
+ abstract public function error (): array ;
1739
1743
1740
1744
//--------------------------------------------------------------------
1741
1745
@@ -1744,7 +1748,7 @@ abstract public function error();
1744
1748
*
1745
1749
* @return integer
1746
1750
*/
1747
- abstract public function insertID ();
1751
+ abstract public function insertID (): int ;
1748
1752
1749
1753
//--------------------------------------------------------------------
1750
1754
@@ -1755,7 +1759,7 @@ abstract public function insertID();
1755
1759
*
1756
1760
* @return string
1757
1761
*/
1758
- abstract protected function _listTables ($ constrainByPrefix = false ): string ;
1762
+ abstract protected function _listTables (bool $ constrainByPrefix = false ): string ;
1759
1763
1760
1764
//--------------------------------------------------------------------
1761
1765
@@ -1803,12 +1807,19 @@ abstract protected function _foreignKeyData(string $table): array;
1803
1807
1804
1808
//--------------------------------------------------------------------
1805
1809
1806
- public function __get ($ key )
1810
+ /**
1811
+ * @param string $key
1812
+ *
1813
+ * @return mixed
1814
+ */
1815
+ public function __get (string $ key )
1807
1816
{
1808
1817
if (property_exists ($ this , $ key ))
1809
1818
{
1810
1819
return $ this ->$ key ;
1811
1820
}
1821
+
1822
+ return null ;
1812
1823
}
1813
1824
1814
1825
//--------------------------------------------------------------------
0 commit comments