From 80ac569621b684ef77b638d147a8727789919a4e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 9 Jun 2017 21:21:19 +0200 Subject: [PATCH] fixed phpDoc --- src/Dibi/Bridges/Tracy/Panel.php | 6 ++--- src/Dibi/Connection.php | 10 ++++----- src/Dibi/DataSource.php | 8 +++---- src/Dibi/DateTime.php | 3 +++ src/Dibi/Drivers/FirebirdDriver.php | 33 +++++++++++++++++++++++----- src/Dibi/Drivers/MsSqlDriver.php | 33 +++++++++++++++++++++++----- src/Dibi/Drivers/MySqlDriver.php | 33 +++++++++++++++++++++++----- src/Dibi/Drivers/MySqliDriver.php | 34 ++++++++++++++++++++++++----- src/Dibi/Drivers/OdbcDriver.php | 33 +++++++++++++++++++++++----- src/Dibi/Drivers/OracleDriver.php | 33 +++++++++++++++++++++++----- src/Dibi/Drivers/PdoDriver.php | 29 +++++++++++++++++++++--- src/Dibi/Drivers/PostgreDriver.php | 33 +++++++++++++++++++++++----- src/Dibi/Drivers/Sqlite3Driver.php | 33 +++++++++++++++++++++++----- src/Dibi/Drivers/SqlsrvDriver.php | 33 +++++++++++++++++++++++----- src/Dibi/Fluent.php | 4 ++-- src/Dibi/Reflection/Column.php | 20 ++++++++--------- src/Dibi/Result.php | 10 ++++----- src/Dibi/ResultIterator.php | 2 +- src/Dibi/Strict.php | 2 +- src/Dibi/dibi.php | 8 +++---- src/Dibi/interfaces.php | 25 ++++++++++++++++++++- 21 files changed, 340 insertions(+), 85 deletions(-) diff --git a/src/Dibi/Bridges/Tracy/Panel.php b/src/Dibi/Bridges/Tracy/Panel.php index 7327a43f..df1909d0 100644 --- a/src/Dibi/Bridges/Tracy/Panel.php +++ b/src/Dibi/Bridges/Tracy/Panel.php @@ -63,7 +63,7 @@ class Panel implements Tracy\IBarPanel /** * Returns blue-screen custom tab. - * @return mixed + * @return array|NULL */ public static function renderException($e) { @@ -78,7 +78,7 @@ class Panel implements Tracy\IBarPanel /** * Returns HTML code for custom tab. (Tracy\IBarPanel) - * @return mixed + * @return string */ public function getTab() { @@ -96,7 +96,7 @@ class Panel implements Tracy\IBarPanel /** * Returns HTML code for custom panel. (Tracy\IBarPanel) - * @return mixed + * @return string|NULL */ public function getPanel() { diff --git a/src/Dibi/Connection.php b/src/Dibi/Connection.php index fceeda0f..22869ca6 100644 --- a/src/Dibi/Connection.php +++ b/src/Dibi/Connection.php @@ -225,7 +225,7 @@ class Connection /** * Generates (translates) and executes SQL query. * @param array|mixed one or more arguments - * @return Result|int result set object (if any) + * @return Result|int result set or number of affected rows * @throws Exception */ final public function query($args) @@ -303,7 +303,7 @@ class Connection /** * Executes the SQL query. * @param string SQL statement. - * @return Result|int result set object (if any) + * @return Result|int result set or number of affected rows * @throws Exception */ final public function nativeQuery($sql) @@ -473,7 +473,7 @@ class Connection /** - * @param string column name + * @param mixed column name * @return Fluent */ public function select($args) @@ -555,7 +555,7 @@ class Connection /** * Executes SQL query and fetch result - shortcut for query() & fetch(). * @param array|mixed one or more arguments - * @return Row|bool + * @return Row|FALSE * @throws Exception */ public function fetch($args) @@ -581,7 +581,7 @@ class Connection /** * Executes SQL query and fetch first column - shortcut for query() & fetchSingle(). * @param array|mixed one or more arguments - * @return string|bool + * @return mixed * @throws Exception */ public function fetchSingle($args) diff --git a/src/Dibi/DataSource.php b/src/Dibi/DataSource.php index 9c925c5f..1511506f 100644 --- a/src/Dibi/DataSource.php +++ b/src/Dibi/DataSource.php @@ -40,10 +40,10 @@ class DataSource implements IDataSource /** @var array */ private $conds = []; - /** @var int */ + /** @var int|NULL */ private $offset; - /** @var int */ + /** @var int|NULL */ private $limit; @@ -118,7 +118,7 @@ class DataSource implements IDataSource /** * Limits number of rows. - * @param int limit + * @param int|NULL limit * @param int offset * @return self */ @@ -168,7 +168,7 @@ class DataSource implements IDataSource /** * Generates, executes SQL query and fetches the single row. - * @return Row|FALSE array on success, FALSE if no next record + * @return Row|FALSE */ public function fetch() { diff --git a/src/Dibi/DateTime.php b/src/Dibi/DateTime.php index 142842fc..036420f0 100644 --- a/src/Dibi/DateTime.php +++ b/src/Dibi/DateTime.php @@ -15,6 +15,9 @@ class DateTime extends \DateTime { use Strict; + /** + * @param string|int + */ public function __construct($time = 'now', \DateTimeZone $timezone = NULL) { if (is_numeric($time)) { diff --git a/src/Dibi/Drivers/FirebirdDriver.php b/src/Dibi/Drivers/FirebirdDriver.php index 401d8db5..77e90ae3 100644 --- a/src/Dibi/Drivers/FirebirdDriver.php +++ b/src/Dibi/Drivers/FirebirdDriver.php @@ -28,16 +28,16 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector const ERROR_EXCEPTION_THROWN = -836; - /** @var resource Connection resource */ + /** @var resource|NULL */ private $connection; - /** @var resource Resultset resource */ + /** @var resource|NULL */ private $resultSet; /** @var bool */ private $autoFree = TRUE; - /** @var resource Resultset resource */ + /** @var resource|NULL */ private $transaction; /** @var bool */ @@ -215,7 +215,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Returns the connection resource. - * @return resource + * @return resource|NULL */ public function getResource() { @@ -260,24 +260,40 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param string + * @return string + */ public function escapeBinary($value) { return "'" . str_replace("'", "''", $value) . "'"; } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { return '"' . str_replace('"', '""', $value). '"'; } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 1 : 0; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -287,6 +303,10 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -329,6 +349,9 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -411,7 +434,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Returns the result set resource. - * @return resource + * @return resource|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/MsSqlDriver.php b/src/Dibi/Drivers/MsSqlDriver.php index 29ad3302..bd39de38 100644 --- a/src/Dibi/Drivers/MsSqlDriver.php +++ b/src/Dibi/Drivers/MsSqlDriver.php @@ -26,10 +26,10 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver { use Dibi\Strict; - /** @var resource Connection resource */ + /** @var resource|NULL */ private $connection; - /** @var resource Resultset resource */ + /** @var resource|NULL */ private $resultSet; /** @var bool */ @@ -164,7 +164,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the connection resource. - * @return mixed + * @return resource|NULL */ public function getResource() { @@ -200,7 +200,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -209,12 +209,20 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param string + * @return string + */ public function escapeBinary($value) { return "'" . str_replace("'", "''", $value) . "'"; } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { // @see https://msdn.microsoft.com/en-us/library/ms176027.aspx @@ -222,12 +230,20 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 1 : 0; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -237,6 +253,10 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -280,6 +300,9 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -375,7 +398,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the result set resource. - * @return mixed + * @return resource|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/MySqlDriver.php b/src/Dibi/Drivers/MySqlDriver.php index d7d8a0c9..d816e5d5 100644 --- a/src/Dibi/Drivers/MySqlDriver.php +++ b/src/Dibi/Drivers/MySqlDriver.php @@ -36,10 +36,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver const ERROR_DUPLICATE_ENTRY = 1062; const ERROR_DATA_TRUNCATED = 1265; - /** @var resource Connection resource */ + /** @var resource|NULL */ private $connection; - /** @var resource Resultset resource */ + /** @var resource|NULL */ private $resultSet; /** @var bool */ @@ -243,7 +243,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the connection resource. - * @return mixed + * @return resource|NULL */ public function getResource() { @@ -279,7 +279,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -291,6 +291,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param string + * @return string + */ public function escapeBinary($value) { if (!is_resource($this->connection)) { @@ -300,6 +304,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { // @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html @@ -307,12 +315,20 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 1 : 0; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -322,6 +338,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -365,6 +385,9 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -469,7 +492,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the result set resource. - * @return mixed + * @return resource|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/MySqliDriver.php b/src/Dibi/Drivers/MySqliDriver.php index 4b762351..b83acfca 100644 --- a/src/Dibi/Drivers/MySqliDriver.php +++ b/src/Dibi/Drivers/MySqliDriver.php @@ -37,10 +37,10 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver const ERROR_DUPLICATE_ENTRY = 1062; const ERROR_DATA_TRUNCATED = 1265; - /** @var mysqli Connection resource */ + /** @var \mysqli|NULL */ private $connection; - /** @var mysqli_result Resultset resource */ + /** @var \mysqli_result|NULL */ private $resultSet; /** @var bool */ @@ -258,7 +258,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the connection resource. - * @return mysqli + * @return \mysqli */ public function getResource() { @@ -278,7 +278,6 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver /** * Result set driver factory. - * @param mysqli_result * @return Dibi\ResultDriver */ public function createResultDriver(\mysqli_result $resource) @@ -294,7 +293,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -303,24 +302,40 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param string + * @return string + */ public function escapeBinary($value) { return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'"; } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { return '`' . str_replace('`', '``', $value) . '`'; } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 1 : 0; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -330,6 +345,10 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -373,6 +392,9 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -488,7 +510,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the result set resource. - * @return mysqli_result + * @return \mysqli_result|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/OdbcDriver.php b/src/Dibi/Drivers/OdbcDriver.php index ee7079a6..6ba27a38 100644 --- a/src/Dibi/Drivers/OdbcDriver.php +++ b/src/Dibi/Drivers/OdbcDriver.php @@ -25,10 +25,10 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector { use Dibi\Strict; - /** @var resource Connection resource */ + /** @var resource|NULL */ private $connection; - /** @var resource Resultset resource */ + /** @var resource|NULL */ private $resultSet; /** @var bool */ @@ -189,7 +189,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Returns the connection resource. - * @return mixed + * @return resource|NULL */ public function getResource() { @@ -225,7 +225,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -234,24 +234,40 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param string + * @return string + */ public function escapeBinary($value) { return "'" . str_replace("'", "''", $value) . "'"; } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { return '[' . str_replace(['[', ']'], ['[[', ']]'], $value) . ']'; } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 1 : 0; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -261,6 +277,10 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -304,6 +324,9 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -413,7 +436,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Returns the result set resource. - * @return mixed + * @return resource|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/OracleDriver.php b/src/Dibi/Drivers/OracleDriver.php index 8109da72..a522a36a 100644 --- a/src/Dibi/Drivers/OracleDriver.php +++ b/src/Dibi/Drivers/OracleDriver.php @@ -29,10 +29,10 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector { use Dibi\Strict; - /** @var resource Connection resource */ + /** @var resource|NULL */ private $connection; - /** @var resource Resultset resource */ + /** @var resource|NULL */ private $resultSet; /** @var bool */ @@ -212,7 +212,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Returns the connection resource. - * @return mixed + * @return resource|NULL */ public function getResource() { @@ -248,7 +248,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -257,12 +257,20 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param string + * @return string + */ public function escapeBinary($value) { return "'" . str_replace("'", "''", $value) . "'"; // TODO: not tested } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { // @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm @@ -270,12 +278,20 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 1 : 0; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -285,6 +301,10 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -329,6 +349,9 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -427,7 +450,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Returns the result set resource. - * @return mixed + * @return resource|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/PdoDriver.php b/src/Dibi/Drivers/PdoDriver.php index 075b95fd..f41de79f 100644 --- a/src/Dibi/Drivers/PdoDriver.php +++ b/src/Dibi/Drivers/PdoDriver.php @@ -30,7 +30,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver /** @var PDO Connection resource */ private $connection; - /** @var \PDOStatement Resultset resource */ + /** @var \PDOStatement|NULL Resultset resource */ private $resultSet; /** @var int|FALSE Affected rows */ @@ -254,7 +254,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -267,6 +267,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param string + * @return string + */ public function escapeBinary($value) { if ($this->driverName === 'odbc') { @@ -277,6 +281,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { switch ($this->driverName) { @@ -304,6 +312,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param bool + * @return string + */ public function escapeBool($value) { if ($this->driverName === 'pgsql') { @@ -314,6 +326,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -323,6 +339,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -394,6 +414,9 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -548,7 +571,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the result set resource. - * @return \PDOStatement + * @return \PDOStatement|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/PostgreDriver.php b/src/Dibi/Drivers/PostgreDriver.php index 463ff3e7..1b307e95 100644 --- a/src/Dibi/Drivers/PostgreDriver.php +++ b/src/Dibi/Drivers/PostgreDriver.php @@ -26,10 +26,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector { use Dibi\Strict; - /** @var resource Connection resource */ + /** @var resource|NULL */ private $connection; - /** @var resource Resultset resource */ + /** @var resource|NULL */ private $resultSet; /** @var bool */ @@ -256,7 +256,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Returns the connection resource. - * @return mixed + * @return resource|NULL */ public function getResource() { @@ -292,7 +292,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -304,6 +304,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param string + * @return string + */ public function escapeBinary($value) { if (!is_resource($this->connection)) { @@ -313,6 +317,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { // @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS @@ -320,12 +328,20 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 'TRUE' : 'FALSE'; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -335,6 +351,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -380,6 +400,9 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -475,7 +498,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector /** * Returns the result set resource. - * @return mixed + * @return resource|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/Sqlite3Driver.php b/src/Dibi/Drivers/Sqlite3Driver.php index 980d58c7..a6d4b8ff 100644 --- a/src/Dibi/Drivers/Sqlite3Driver.php +++ b/src/Dibi/Drivers/Sqlite3Driver.php @@ -27,10 +27,10 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver { use Dibi\Strict; - /** @var SQLite3 Connection resource */ + /** @var SQLite3|NULL */ private $connection; - /** @var \SQLite3Result Resultset resource */ + /** @var \SQLite3Result|NULL */ private $resultSet; /** @var bool */ @@ -209,7 +209,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the connection resource. - * @return mixed + * @return SQLite3 */ public function getResource() { @@ -245,7 +245,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -254,24 +254,40 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param string + * @return string + */ public function escapeBinary($value) { return "X'" . bin2hex((string) $value) . "'"; } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { return '[' . strtr($value, '[]', ' ') . ']'; } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 1 : 0; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -281,6 +297,10 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -324,6 +344,9 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -431,7 +454,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the result set resource. - * @return mixed + * @return \SQLite3Result|NULL */ public function getResultResource() { diff --git a/src/Dibi/Drivers/SqlsrvDriver.php b/src/Dibi/Drivers/SqlsrvDriver.php index 3e6192e2..b9ad53f6 100644 --- a/src/Dibi/Drivers/SqlsrvDriver.php +++ b/src/Dibi/Drivers/SqlsrvDriver.php @@ -29,10 +29,10 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver { use Dibi\Strict; - /** @var resource Connection resource */ + /** @var resource|NULL */ private $connection; - /** @var resource Resultset resource */ + /** @var resource|NULL */ private $resultSet; /** @var bool */ @@ -188,7 +188,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the connection resource. - * @return mixed + * @return resource|NULL */ public function getResource() { @@ -224,7 +224,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ public function escapeText($value) @@ -233,12 +233,20 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param string + * @return string + */ public function escapeBinary($value) { return "'" . str_replace("'", "''", $value) . "'"; } + /** + * @param string + * @return string + */ public function escapeIdentifier($value) { // @see https://msdn.microsoft.com/en-us/library/ms176027.aspx @@ -246,12 +254,20 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param bool + * @return string + */ public function escapeBool($value) { return $value ? 1 : 0; } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDate($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -261,6 +277,10 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver } + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ public function escapeDateTime($value) { if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { @@ -304,6 +324,9 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ public function applyLimit(&$sql, $limit, $offset) @@ -405,7 +428,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver /** * Returns the result set resource. - * @return mixed + * @return resource|NULL */ public function getResultResource() { diff --git a/src/Dibi/Fluent.php b/src/Dibi/Fluent.php index ab095e5a..8e064a18 100644 --- a/src/Dibi/Fluent.php +++ b/src/Dibi/Fluent.php @@ -300,7 +300,7 @@ class Fluent implements IDataSource /** * Generates and executes SQL query. * @param mixed what to return? - * @return Result|int result set object (if any) + * @return Result|int result set or number of affected rows * @throws Exception */ public function execute($return = NULL) @@ -319,7 +319,7 @@ class Fluent implements IDataSource /** * Generates, executes SQL query and fetches the single row. - * @return Row|FALSE array on success, FALSE if no next record + * @return Row|FALSE */ public function fetch() { diff --git a/src/Dibi/Reflection/Column.php b/src/Dibi/Reflection/Column.php index b8b34ace..7f6593de 100644 --- a/src/Dibi/Reflection/Column.php +++ b/src/Dibi/Reflection/Column.php @@ -19,10 +19,10 @@ use Dibi\Type; * @property-read Table $table * @property-read string $type * @property-read mixed $nativeType - * @property-read int $size - * @property-read bool $unsigned - * @property-read bool $nullable - * @property-read bool $autoIncrement + * @property-read int|NULL $size + * @property-read bool|NULL $unsigned + * @property-read bool|NULL $nullable + * @property-read bool|NULL $autoIncrement * @property-read mixed $default */ class Column @@ -83,7 +83,7 @@ class Column /** - * @return string + * @return string|NULL */ public function getTableName() { @@ -101,7 +101,7 @@ class Column /** - * @return mixed + * @return string */ public function getNativeType() { @@ -110,7 +110,7 @@ class Column /** - * @return int + * @return int|NULL */ public function getSize() { @@ -119,7 +119,7 @@ class Column /** - * @return bool + * @return bool|NULL */ public function isUnsigned() { @@ -128,7 +128,7 @@ class Column /** - * @return bool + * @return bool|NULL */ public function isNullable() { @@ -137,7 +137,7 @@ class Column /** - * @return bool + * @return bool|NULL */ public function isAutoIncrement() { diff --git a/src/Dibi/Result.php b/src/Dibi/Result.php index bd1cbd6b..79921dcd 100644 --- a/src/Dibi/Result.php +++ b/src/Dibi/Result.php @@ -184,7 +184,7 @@ class Result implements IDataSource /** * Fetches the row at current position, process optional type conversion. * and moves the internal cursor to the next position - * @return Row|FALSE array on success, FALSE if no next record + * @return Row|FALSE */ final public function fetch() { @@ -558,9 +558,9 @@ class Result implements IDataSource /** - * Sets data format. - * @param string type (use constant Type::*) - * @param string format + * Sets date format. + * @param string + * @param string|NULL format * @return self */ final public function setFormat($type, $format) @@ -572,7 +572,7 @@ class Result implements IDataSource /** * Returns data format. - * @return string + * @return string|NULL */ final public function getFormat($type) { diff --git a/src/Dibi/ResultIterator.php b/src/Dibi/ResultIterator.php index 0767fef5..473d768b 100644 --- a/src/Dibi/ResultIterator.php +++ b/src/Dibi/ResultIterator.php @@ -27,7 +27,7 @@ class ResultIterator implements \Iterator, \Countable /** @var Result */ private $result; - /** @var int */ + /** @var mixed */ private $row; /** @var int */ diff --git a/src/Dibi/Strict.php b/src/Dibi/Strict.php index 6b5e9a91..e3a4329c 100644 --- a/src/Dibi/Strict.php +++ b/src/Dibi/Strict.php @@ -105,7 +105,7 @@ trait Strict /** * @param string method name - * @param callabke + * @param callable * @return mixed */ public static function extensionMethod($name, $callback = NULL) diff --git a/src/Dibi/dibi.php b/src/Dibi/dibi.php index a4110d32..c4b3e8b6 100644 --- a/src/Dibi/dibi.php +++ b/src/Dibi/dibi.php @@ -167,7 +167,7 @@ class dibi /** * Generates and executes SQL query - Monostate for Dibi\Connection::query(). * @param array|mixed one or more arguments - * @return Dibi\Result|int result set object (if any) + * @return Dibi\Result|int result set or number of affected rows * @throws Dibi\Exception */ public static function query($args) @@ -180,7 +180,7 @@ class dibi /** * Executes the SQL query - Monostate for Dibi\Connection::nativeQuery(). * @param string SQL statement. - * @return Dibi\Result|int result set object (if any) + * @return Dibi\Result|int result set or number of affected rows */ public static function nativeQuery($sql) { @@ -241,7 +241,7 @@ class dibi /** * Executes SQL query and fetch first column - Monostate for Dibi\Connection::query() & fetchSingle(). * @param array|mixed one or more arguments - * @return string + * @return mixed * @throws Dibi\Exception */ public static function fetchSingle($args) @@ -382,7 +382,7 @@ class dibi /** - * @param string column name + * @param mixed column name * @return Dibi\Fluent */ public static function select($args) diff --git a/src/Dibi/interfaces.php b/src/Dibi/interfaces.php index a3b5dd74..f7292274 100644 --- a/src/Dibi/interfaces.php +++ b/src/Dibi/interfaces.php @@ -97,19 +97,39 @@ interface Driver /** * Encodes data for use in a SQL statement. - * @param mixed value + * @param string value * @return string encoded value */ function escapeText($value); + /** + * @param string + * @return string + */ function escapeBinary($value); + /** + * @param string + * @return string + */ function escapeIdentifier($value); + /** + * @param bool + * @return string + */ function escapeBool($value); + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ function escapeDate($value); + /** + * @param \DateTime|\DateTimeInterface|string|int + * @return string + */ function escapeDateTime($value); /** @@ -122,6 +142,9 @@ interface Driver /** * Injects LIMIT/OFFSET to the SQL query. + * @param string + * @param int|NULL + * @param int|NULL * @return void */ function applyLimit(&$sql, $limit, $offset);