mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 21:58:10 +02:00
added property typehints
This commit is contained in:
@@ -19,11 +19,8 @@ use Tracy;
|
||||
*/
|
||||
class DibiExtension22 extends Nette\DI\CompilerExtension
|
||||
{
|
||||
/** @var bool|null */
|
||||
private $debugMode;
|
||||
|
||||
/** @var bool|null */
|
||||
private $cliMode;
|
||||
private ?bool $debugMode;
|
||||
private ?bool $cliMode;
|
||||
|
||||
|
||||
public function __construct(?bool $debugMode = null, ?bool $cliMode = null)
|
||||
|
@@ -20,17 +20,10 @@ use Tracy;
|
||||
*/
|
||||
class Panel implements Tracy\IBarPanel
|
||||
{
|
||||
/** @var int maximum SQL length */
|
||||
public static $maxLength = 1000;
|
||||
|
||||
/** @var bool|string explain queries? */
|
||||
public $explain;
|
||||
|
||||
/** @var int */
|
||||
public $filter;
|
||||
|
||||
/** @var array */
|
||||
private $events = [];
|
||||
public static int $maxLength = 1000;
|
||||
public bool|string $explain;
|
||||
public int $filter;
|
||||
private array $events = [];
|
||||
|
||||
|
||||
public function __construct($explain = true, ?int $filter = null)
|
||||
|
@@ -20,25 +20,16 @@ use Traversable;
|
||||
*/
|
||||
class Connection implements IConnection
|
||||
{
|
||||
/** @var array of function (Event $event); Occurs after query is executed */
|
||||
public $onEvent = [];
|
||||
|
||||
/** @var array Current connection configuration */
|
||||
private $config;
|
||||
/** function (Event $event); Occurs after query is executed */
|
||||
public ?array $onEvent = [];
|
||||
private array $config;
|
||||
|
||||
/** @var string[] resultset formats */
|
||||
private $formats;
|
||||
|
||||
/** @var Driver|null */
|
||||
private $driver;
|
||||
|
||||
/** @var Translator|null */
|
||||
private $translator;
|
||||
|
||||
/** @var HashMap Substitutes for identifiers */
|
||||
private $substitutes;
|
||||
|
||||
private $transactionDepth = 0;
|
||||
private array $formats;
|
||||
private ?Driver $driver = null;
|
||||
private ?Translator $translator = null;
|
||||
private HashMap $substitutes;
|
||||
private int $transactionDepth = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -15,35 +15,16 @@ namespace Dibi;
|
||||
*/
|
||||
class DataSource implements IDataSource
|
||||
{
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
/** @var string */
|
||||
private $sql;
|
||||
|
||||
/** @var Result|null */
|
||||
private $result;
|
||||
|
||||
/** @var int|null */
|
||||
private $count;
|
||||
|
||||
/** @var int|null */
|
||||
private $totalCount;
|
||||
|
||||
/** @var array */
|
||||
private $cols = [];
|
||||
|
||||
/** @var array */
|
||||
private $sorting = [];
|
||||
|
||||
/** @var array */
|
||||
private $conds = [];
|
||||
|
||||
/** @var int|null */
|
||||
private $offset;
|
||||
|
||||
/** @var int|null */
|
||||
private $limit;
|
||||
private Connection $connection;
|
||||
private string $sql;
|
||||
private ?Result $result = null;
|
||||
private ?int $count = null;
|
||||
private ?int $totalCount = null;
|
||||
private array $cols = [];
|
||||
private array $sorting = [];
|
||||
private array $conds = [];
|
||||
private ?int $offset = null;
|
||||
private ?int $limit = null;
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -31,11 +31,9 @@ class FirebirdDriver implements Dibi\Driver
|
||||
/** @var resource */
|
||||
private $connection;
|
||||
|
||||
/** @var resource|null */
|
||||
/** @var ?resource */
|
||||
private $transaction;
|
||||
|
||||
/** @var bool */
|
||||
private $inTransaction = false;
|
||||
private bool $inTransaction = false;
|
||||
|
||||
|
||||
/** @throws Dibi\NotSupportedException */
|
||||
|
@@ -17,8 +17,7 @@ use Dibi;
|
||||
*/
|
||||
class FirebirdReflector implements Dibi\Reflector
|
||||
{
|
||||
/** @var Dibi\Driver */
|
||||
private $driver;
|
||||
private Dibi\Driver $driver;
|
||||
|
||||
|
||||
public function __construct(Dibi\Driver $driver)
|
||||
|
@@ -18,8 +18,7 @@ use Dibi;
|
||||
*/
|
||||
class MySqlReflector implements Dibi\Reflector
|
||||
{
|
||||
/** @var Dibi\Driver */
|
||||
private $driver;
|
||||
private Dibi\Driver $driver;
|
||||
|
||||
|
||||
public function __construct(Dibi\Driver $driver)
|
||||
|
@@ -33,16 +33,11 @@ use Dibi;
|
||||
class MySqliDriver implements Dibi\Driver
|
||||
{
|
||||
public const ERROR_ACCESS_DENIED = 1045;
|
||||
|
||||
public const ERROR_DUPLICATE_ENTRY = 1062;
|
||||
|
||||
public const ERROR_DATA_TRUNCATED = 1265;
|
||||
|
||||
/** @var \mysqli */
|
||||
private $connection;
|
||||
|
||||
/** @var bool Is buffered (seekable and countable)? */
|
||||
private $buffered;
|
||||
private \mysqli $connection;
|
||||
private bool $buffered = false;
|
||||
|
||||
|
||||
/** @throws Dibi\NotSupportedException */
|
||||
|
@@ -17,11 +17,8 @@ use Dibi;
|
||||
*/
|
||||
class MySqliResult implements Dibi\ResultDriver
|
||||
{
|
||||
/** @var \mysqli_result */
|
||||
private $resultSet;
|
||||
|
||||
/** @var bool Is buffered (seekable and countable)? */
|
||||
private $buffered;
|
||||
private \mysqli_result $resultSet;
|
||||
private bool $buffered;
|
||||
|
||||
|
||||
public function __construct(\mysqli_result $resultSet, bool $buffered)
|
||||
|
@@ -17,8 +17,7 @@ use Dibi;
|
||||
*/
|
||||
class NoDataResult implements Dibi\ResultDriver
|
||||
{
|
||||
/** @var int */
|
||||
private $rows;
|
||||
private int $rows;
|
||||
|
||||
|
||||
public function __construct(int $rows)
|
||||
|
@@ -27,12 +27,8 @@ class OdbcDriver implements Dibi\Driver
|
||||
{
|
||||
/** @var resource */
|
||||
private $connection;
|
||||
|
||||
/** @var int|null Affected rows */
|
||||
private $affectedRows;
|
||||
|
||||
/** @var bool */
|
||||
private $microseconds = true;
|
||||
private ?int $affectedRows;
|
||||
private bool $microseconds = true;
|
||||
|
||||
|
||||
/** @throws Dibi\NotSupportedException */
|
||||
|
@@ -17,8 +17,7 @@ use Dibi;
|
||||
*/
|
||||
class OdbcReflector implements Dibi\Reflector
|
||||
{
|
||||
/** @var Dibi\Driver */
|
||||
private $driver;
|
||||
private Dibi\Driver $driver;
|
||||
|
||||
|
||||
public function __construct(Dibi\Driver $driver)
|
||||
|
@@ -19,9 +19,7 @@ class OdbcResult implements Dibi\ResultDriver
|
||||
{
|
||||
/** @var resource */
|
||||
private $resultSet;
|
||||
|
||||
/** @var int Cursor */
|
||||
private $row = 0;
|
||||
private int $row = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -29,15 +29,9 @@ class OracleDriver implements Dibi\Driver
|
||||
{
|
||||
/** @var resource */
|
||||
private $connection;
|
||||
|
||||
/** @var bool */
|
||||
private $autocommit = true;
|
||||
|
||||
/** @var bool use native datetime format */
|
||||
private $nativeDate;
|
||||
|
||||
/** @var int|null Number of affected rows */
|
||||
private $affectedRows;
|
||||
private bool $autocommit = true;
|
||||
private bool $nativeDate;
|
||||
private ?int $affectedRows;
|
||||
|
||||
|
||||
/** @throws Dibi\NotSupportedException */
|
||||
|
@@ -17,8 +17,7 @@ use Dibi;
|
||||
*/
|
||||
class OracleReflector implements Dibi\Reflector
|
||||
{
|
||||
/** @var Dibi\Driver */
|
||||
private $driver;
|
||||
private Dibi\Driver $driver;
|
||||
|
||||
|
||||
public function __construct(Dibi\Driver $driver)
|
||||
|
@@ -27,17 +27,10 @@ use PDO;
|
||||
*/
|
||||
class PdoDriver implements Dibi\Driver
|
||||
{
|
||||
/** @var PDO|null Connection resource */
|
||||
private $connection;
|
||||
|
||||
/** @var int|null Affected rows */
|
||||
private $affectedRows;
|
||||
|
||||
/** @var string */
|
||||
private $driverName;
|
||||
|
||||
/** @var string */
|
||||
private $serverVersion = '';
|
||||
private ?PDO $connection;
|
||||
private ?int $affectedRows;
|
||||
private string $driverName;
|
||||
private string $serverVersion = '';
|
||||
|
||||
|
||||
/** @throws Dibi\NotSupportedException */
|
||||
|
@@ -19,11 +19,8 @@ use PDO;
|
||||
*/
|
||||
class PdoResult implements Dibi\ResultDriver
|
||||
{
|
||||
/** @var \PDOStatement|null */
|
||||
private $resultSet;
|
||||
|
||||
/** @var string */
|
||||
private $driverName;
|
||||
private ?\PDOStatement $resultSet;
|
||||
private string $driverName;
|
||||
|
||||
|
||||
public function __construct(\PDOStatement $resultSet, string $driverName)
|
||||
|
@@ -30,9 +30,7 @@ class PostgreDriver implements Dibi\Driver
|
||||
{
|
||||
/** @var resource|PgSql\Connection */
|
||||
private $connection;
|
||||
|
||||
/** @var int|null Affected rows */
|
||||
private $affectedRows;
|
||||
private ?int $affectedRows;
|
||||
|
||||
|
||||
/** @throws Dibi\NotSupportedException */
|
||||
@@ -138,7 +136,7 @@ class PostgreDriver implements Dibi\Driver
|
||||
$message = substr($message, strlen($m[0]));
|
||||
}
|
||||
|
||||
if ($code === '0A000' && strpos($message, 'truncate') !== false) {
|
||||
if ($code === '0A000' && str_contains($message, 'truncate')) {
|
||||
return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql);
|
||||
|
||||
} elseif ($code === '23502') {
|
||||
|
@@ -17,11 +17,8 @@ use Dibi;
|
||||
*/
|
||||
class PostgreReflector implements Dibi\Reflector
|
||||
{
|
||||
/** @var Dibi\Driver */
|
||||
private $driver;
|
||||
|
||||
/** @var string */
|
||||
private $version;
|
||||
private Dibi\Driver $driver;
|
||||
private string $version;
|
||||
|
||||
|
||||
public function __construct(Dibi\Driver $driver, string $version)
|
||||
|
@@ -25,14 +25,9 @@ use SQLite3;
|
||||
*/
|
||||
class SqliteDriver implements Dibi\Driver
|
||||
{
|
||||
/** @var SQLite3 */
|
||||
private $connection;
|
||||
|
||||
/** @var string Date format */
|
||||
private $fmtDate;
|
||||
|
||||
/** @var string Datetime format */
|
||||
private $fmtDateTime;
|
||||
private SQLite3 $connection;
|
||||
private string $fmtDate;
|
||||
private string $fmtDateTime;
|
||||
|
||||
|
||||
/** @throws Dibi\NotSupportedException */
|
||||
@@ -100,19 +95,19 @@ class SqliteDriver implements Dibi\Driver
|
||||
if ($code !== 19) {
|
||||
return new Dibi\DriverException($message, $code, $sql);
|
||||
|
||||
} elseif (strpos($message, 'must be unique') !== false
|
||||
|| strpos($message, 'is not unique') !== false
|
||||
|| strpos($message, 'UNIQUE constraint failed') !== false
|
||||
} elseif (str_contains($message, 'must be unique')
|
||||
|| str_contains($message, 'is not unique')
|
||||
|| str_contains($message, 'UNIQUE constraint failed')
|
||||
) {
|
||||
return new Dibi\UniqueConstraintViolationException($message, $code, $sql);
|
||||
|
||||
} elseif (strpos($message, 'may not be null') !== false
|
||||
|| strpos($message, 'NOT NULL constraint failed') !== false
|
||||
} elseif (str_contains($message, 'may not be null')
|
||||
|| str_contains($message, 'NOT NULL constraint failed')
|
||||
) {
|
||||
return new Dibi\NotNullConstraintViolationException($message, $code, $sql);
|
||||
|
||||
} elseif (strpos($message, 'foreign key constraint failed') !== false
|
||||
|| strpos($message, 'FOREIGN KEY constraint failed') !== false
|
||||
} elseif (str_contains($message, 'foreign key constraint failed')
|
||||
|| str_contains($message, 'FOREIGN KEY constraint failed')
|
||||
) {
|
||||
return new Dibi\ForeignKeyConstraintViolationException($message, $code, $sql);
|
||||
|
||||
|
@@ -17,8 +17,7 @@ use Dibi;
|
||||
*/
|
||||
class SqliteReflector implements Dibi\Reflector
|
||||
{
|
||||
/** @var Dibi\Driver */
|
||||
private $driver;
|
||||
private Dibi\Driver $driver;
|
||||
|
||||
|
||||
public function __construct(Dibi\Driver $driver)
|
||||
|
@@ -18,8 +18,7 @@ use Dibi\Helpers;
|
||||
*/
|
||||
class SqliteResult implements Dibi\ResultDriver
|
||||
{
|
||||
/** @var \SQLite3Result */
|
||||
private $resultSet;
|
||||
private \SQLite3Result $resultSet;
|
||||
|
||||
|
||||
public function __construct(\SQLite3Result $resultSet)
|
||||
|
@@ -29,12 +29,8 @@ class SqlsrvDriver implements Dibi\Driver
|
||||
{
|
||||
/** @var resource */
|
||||
private $connection;
|
||||
|
||||
/** @var int|null Affected rows */
|
||||
private $affectedRows;
|
||||
|
||||
/** @var string */
|
||||
private $version = '';
|
||||
private ?int $affectedRows;
|
||||
private string $version = '';
|
||||
|
||||
|
||||
/** @throws Dibi\NotSupportedException */
|
||||
|
@@ -17,8 +17,7 @@ use Dibi;
|
||||
*/
|
||||
class SqlsrvReflector implements Dibi\Reflector
|
||||
{
|
||||
/** @var Dibi\Driver */
|
||||
private $driver;
|
||||
private Dibi\Driver $driver;
|
||||
|
||||
|
||||
public function __construct(Dibi\Driver $driver)
|
||||
|
@@ -29,26 +29,13 @@ class Event
|
||||
TRANSACTION = 448, // BEGIN | COMMIT | ROLLBACK
|
||||
ALL = 1023;
|
||||
|
||||
/** @var Connection */
|
||||
public $connection;
|
||||
|
||||
/** @var int */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $sql;
|
||||
|
||||
/** @var Result|DriverException|null */
|
||||
public $result;
|
||||
|
||||
/** @var float */
|
||||
public $time;
|
||||
|
||||
/** @var int|null */
|
||||
public $count;
|
||||
|
||||
/** @var array|null */
|
||||
public $source;
|
||||
public Connection $connection;
|
||||
public int $type;
|
||||
public string $sql;
|
||||
public Result|DriverException|null $result;
|
||||
public float $time;
|
||||
public ?int $count = null;
|
||||
public ?array $source = null;
|
||||
|
||||
|
||||
public function __construct(Connection $connection, int $type, ?string $sql = null)
|
||||
|
@@ -15,8 +15,7 @@ namespace Dibi;
|
||||
*/
|
||||
class Expression
|
||||
{
|
||||
/** @var array */
|
||||
private $values;
|
||||
private array $values;
|
||||
|
||||
|
||||
public function __construct(...$values)
|
||||
|
@@ -47,8 +47,7 @@ class Fluent implements IDataSource
|
||||
{
|
||||
public const REMOVE = false;
|
||||
|
||||
/** @var array */
|
||||
public static $masks = [
|
||||
public static array $masks = [
|
||||
'SELECT' => ['SELECT', 'DISTINCT', 'FROM', 'WHERE', 'GROUP BY',
|
||||
'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET', ],
|
||||
'UPDATE' => ['UPDATE', 'SET', 'WHERE', 'ORDER BY', 'LIMIT'],
|
||||
@@ -56,8 +55,8 @@ class Fluent implements IDataSource
|
||||
'DELETE' => ['DELETE', 'FROM', 'USING', 'WHERE', 'ORDER BY', 'LIMIT'],
|
||||
];
|
||||
|
||||
/** @var array default modifiers for arrays */
|
||||
public static $modifiers = [
|
||||
/** default modifiers for arrays */
|
||||
public static array $modifiers = [
|
||||
'SELECT' => '%n',
|
||||
'FROM' => '%n',
|
||||
'IN' => '%in',
|
||||
@@ -69,8 +68,8 @@ class Fluent implements IDataSource
|
||||
'GROUP BY' => '%by',
|
||||
];
|
||||
|
||||
/** @var array clauses separators */
|
||||
public static $separators = [
|
||||
/** clauses separators */
|
||||
public static array $separators = [
|
||||
'SELECT' => ',',
|
||||
'FROM' => ',',
|
||||
'WHERE' => 'AND',
|
||||
@@ -84,41 +83,30 @@ class Fluent implements IDataSource
|
||||
'INTO' => false,
|
||||
];
|
||||
|
||||
/** @var array clauses */
|
||||
public static $clauseSwitches = [
|
||||
/** clauses */
|
||||
public static array $clauseSwitches = [
|
||||
'JOIN' => 'FROM',
|
||||
'INNER JOIN' => 'FROM',
|
||||
'LEFT JOIN' => 'FROM',
|
||||
'RIGHT JOIN' => 'FROM',
|
||||
];
|
||||
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
/** @var array */
|
||||
private $setups = [];
|
||||
|
||||
/** @var string|null */
|
||||
private $command;
|
||||
|
||||
/** @var array */
|
||||
private $clauses = [];
|
||||
|
||||
/** @var array */
|
||||
private $flags = [];
|
||||
|
||||
/** @var array|null */
|
||||
private Connection $connection;
|
||||
private array $setups = [];
|
||||
private ?string $command = null;
|
||||
private array $clauses = [];
|
||||
private array $flags = [];
|
||||
private $cursor;
|
||||
|
||||
/** @var HashMap normalized clauses */
|
||||
private static $normalizer;
|
||||
/** normalized clauses */
|
||||
private static HashMap $normalizer;
|
||||
|
||||
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
|
||||
if (self::$normalizer === null) {
|
||||
if (!isset(self::$normalizer)) {
|
||||
self::$normalizer = new HashMap([self::class, '_formatClause']);
|
||||
}
|
||||
}
|
||||
|
@@ -12,8 +12,7 @@ namespace Dibi;
|
||||
|
||||
class Helpers
|
||||
{
|
||||
/** @var HashMap */
|
||||
private static $types;
|
||||
private static HashMap $types;
|
||||
|
||||
|
||||
/**
|
||||
@@ -209,7 +208,7 @@ class Helpers
|
||||
/** @internal */
|
||||
public static function getTypeCache(): HashMap
|
||||
{
|
||||
if (self::$types === null) {
|
||||
if (!isset(self::$types)) {
|
||||
self::$types = new HashMap([self::class, 'detectType']);
|
||||
}
|
||||
|
||||
|
@@ -15,8 +15,7 @@ namespace Dibi;
|
||||
*/
|
||||
class Literal
|
||||
{
|
||||
/** @var string */
|
||||
private $value;
|
||||
private string $value;
|
||||
|
||||
|
||||
public function __construct($value)
|
||||
|
@@ -17,14 +17,10 @@ use Dibi;
|
||||
*/
|
||||
class FileLogger
|
||||
{
|
||||
/** @var string Name of the file where SQL errors should be logged */
|
||||
public $file;
|
||||
|
||||
/** @var int */
|
||||
public $filter;
|
||||
|
||||
/** @var bool */
|
||||
private $errorsOnly;
|
||||
/** Name of the file where SQL errors should be logged */
|
||||
public string $file;
|
||||
public int $filter;
|
||||
private bool $errorsOnly;
|
||||
|
||||
|
||||
public function __construct(string $file, ?int $filter = null, bool $errorsOnly = false)
|
||||
|
@@ -27,11 +27,11 @@ use Dibi;
|
||||
*/
|
||||
class Column
|
||||
{
|
||||
/** @var Dibi\Reflector|null when created by Result */
|
||||
private $reflector;
|
||||
/** when created by Result */
|
||||
private ?Dibi\Reflector $reflector;
|
||||
|
||||
/** @var array (name, nativetype, [table], [fullname], [size], [nullable], [default], [autoincrement], [vendor]) */
|
||||
private $info;
|
||||
private array $info;
|
||||
|
||||
|
||||
public function __construct(?Dibi\Reflector $reflector, array $info)
|
||||
|
@@ -21,14 +21,11 @@ use Dibi;
|
||||
*/
|
||||
class Database
|
||||
{
|
||||
/** @var Dibi\Reflector */
|
||||
private $reflector;
|
||||
private Dibi\Reflector $reflector;
|
||||
private ?string $name;
|
||||
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/** @var Table[]|null */
|
||||
private $tables;
|
||||
/** @var Table[] */
|
||||
private array $tables;
|
||||
|
||||
|
||||
public function __construct(Dibi\Reflector $reflector, ?string $name = null)
|
||||
@@ -87,7 +84,7 @@ class Database
|
||||
|
||||
protected function init(): void
|
||||
{
|
||||
if ($this->tables === null) {
|
||||
if (!isset($this->tables)) {
|
||||
$this->tables = [];
|
||||
foreach ($this->reflector->getTables() as $info) {
|
||||
$this->tables[strtolower($info['name'])] = new Table($this->reflector, $info);
|
||||
|
@@ -19,11 +19,10 @@ namespace Dibi\Reflection;
|
||||
*/
|
||||
class ForeignKey
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
private string $name;
|
||||
|
||||
/** @var array of [local, foreign, onDelete, onUpdate] */
|
||||
private $references;
|
||||
private array $references;
|
||||
|
||||
|
||||
public function __construct(string $name, array $references)
|
||||
|
@@ -22,7 +22,7 @@ namespace Dibi\Reflection;
|
||||
class Index
|
||||
{
|
||||
/** @var array (name, columns, [unique], [primary]) */
|
||||
private $info;
|
||||
private array $info;
|
||||
|
||||
|
||||
public function __construct(array $info)
|
||||
|
@@ -20,14 +20,13 @@ use Dibi;
|
||||
*/
|
||||
class Result
|
||||
{
|
||||
/** @var Dibi\ResultDriver */
|
||||
private $driver;
|
||||
private Dibi\ResultDriver $driver;
|
||||
|
||||
/** @var Column[]|null */
|
||||
private $columns;
|
||||
private ?array $columns;
|
||||
|
||||
/** @var Column[]|null */
|
||||
private $names;
|
||||
private ?array $names;
|
||||
|
||||
|
||||
public function __construct(Dibi\ResultDriver $driver)
|
||||
@@ -79,7 +78,7 @@ class Result
|
||||
|
||||
protected function initColumns(): void
|
||||
{
|
||||
if ($this->columns === null) {
|
||||
if (!isset($this->columns)) {
|
||||
$this->columns = [];
|
||||
$reflector = $this->driver instanceof Dibi\Reflector
|
||||
? $this->driver
|
||||
|
@@ -25,26 +25,19 @@ use Dibi;
|
||||
*/
|
||||
class Table
|
||||
{
|
||||
/** @var Dibi\Reflector */
|
||||
private $reflector;
|
||||
private Dibi\Reflector $reflector;
|
||||
private string $name;
|
||||
private bool $view;
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
/** @var Column[] */
|
||||
private array $columns;
|
||||
|
||||
/** @var bool */
|
||||
private $view;
|
||||
/** @var ForeignKey[] */
|
||||
private array $foreignKeys;
|
||||
|
||||
/** @var Column[]|null */
|
||||
private $columns;
|
||||
|
||||
/** @var ForeignKey[]|null */
|
||||
private $foreignKeys;
|
||||
|
||||
/** @var Index[]|null */
|
||||
private $indexes;
|
||||
|
||||
/** @var Index|null */
|
||||
private $primaryKey;
|
||||
/** @var Index[] */
|
||||
private array $indexes;
|
||||
private ?Index $primaryKey;
|
||||
|
||||
|
||||
public function __construct(Dibi\Reflector $reflector, array $info)
|
||||
@@ -133,7 +126,7 @@ class Table
|
||||
|
||||
protected function initColumns(): void
|
||||
{
|
||||
if ($this->columns === null) {
|
||||
if (!isset($this->columns)) {
|
||||
$this->columns = [];
|
||||
foreach ($this->reflector->getColumns($this->name) as $info) {
|
||||
$this->columns[strtolower($info['name'])] = new Column($this->reflector, $info);
|
||||
@@ -144,7 +137,7 @@ class Table
|
||||
|
||||
protected function initIndexes(): void
|
||||
{
|
||||
if ($this->indexes === null) {
|
||||
if (!isset($this->indexes)) {
|
||||
$this->initColumns();
|
||||
$this->indexes = [];
|
||||
foreach ($this->reflector->getIndexes($this->name) as $info) {
|
||||
|
@@ -17,26 +17,21 @@ namespace Dibi;
|
||||
*/
|
||||
class Result implements IDataSource
|
||||
{
|
||||
/** @var ResultDriver|null */
|
||||
private $driver;
|
||||
private ?ResultDriver $driver;
|
||||
|
||||
/** @var array Translate table */
|
||||
private $types = [];
|
||||
/** Translate table */
|
||||
private array $types = [];
|
||||
private ?Reflection\Result $meta;
|
||||
|
||||
/** @var Reflection\Result|null */
|
||||
private $meta;
|
||||
/** Already fetched? Used for allowance for first seek(0) */
|
||||
private bool $fetched = false;
|
||||
|
||||
/** @var bool Already fetched? Used for allowance for first seek(0) */
|
||||
private $fetched = false;
|
||||
|
||||
/** @var string|null returned object class */
|
||||
private $rowClass = Row::class;
|
||||
/** returned object class */
|
||||
private ?string $rowClass = Row::class;
|
||||
|
||||
/** @var callable|null returned object factory */
|
||||
private $rowFactory;
|
||||
|
||||
/** @var array format */
|
||||
private $formats = [];
|
||||
private array $formats = [];
|
||||
|
||||
|
||||
public function __construct(ResultDriver $driver, bool $normalize = true)
|
||||
@@ -589,7 +584,7 @@ class Result implements IDataSource
|
||||
*/
|
||||
public function getInfo(): Reflection\Result
|
||||
{
|
||||
if ($this->meta === null) {
|
||||
if (!isset($this->meta)) {
|
||||
$this->meta = new Reflection\Result($this->getResultDriver());
|
||||
}
|
||||
|
||||
|
@@ -15,14 +15,9 @@ namespace Dibi;
|
||||
*/
|
||||
class ResultIterator implements \Iterator, \Countable
|
||||
{
|
||||
/** @var Result */
|
||||
private $result;
|
||||
|
||||
/** @var mixed */
|
||||
private $row;
|
||||
|
||||
/** @var int */
|
||||
private $pointer = 0;
|
||||
private Result $result;
|
||||
private mixed $row;
|
||||
private int $pointer = 0;
|
||||
|
||||
|
||||
public function __construct(Result $result)
|
||||
|
@@ -15,38 +15,19 @@ namespace Dibi;
|
||||
*/
|
||||
final class Translator
|
||||
{
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
/** @var Driver */
|
||||
private $driver;
|
||||
|
||||
/** @var int */
|
||||
private $cursor = 0;
|
||||
|
||||
/** @var array */
|
||||
private $args;
|
||||
private Connection $connection;
|
||||
private Driver $driver;
|
||||
private int $cursor = 0;
|
||||
private array $args;
|
||||
|
||||
/** @var string[] */
|
||||
private $errors;
|
||||
|
||||
/** @var bool */
|
||||
private $comment = false;
|
||||
|
||||
/** @var int */
|
||||
private $ifLevel = 0;
|
||||
|
||||
/** @var int */
|
||||
private $ifLevelStart = 0;
|
||||
|
||||
/** @var int|null */
|
||||
private $limit;
|
||||
|
||||
/** @var int|null */
|
||||
private $offset;
|
||||
|
||||
/** @var HashMap */
|
||||
private $identifiers;
|
||||
private array $errors;
|
||||
private bool $comment = false;
|
||||
private int $ifLevel = 0;
|
||||
private int $ifLevelStart = 0;
|
||||
private ?int $limit = null;
|
||||
private ?int $offset = null;
|
||||
private HashMap $identifiers;
|
||||
|
||||
|
||||
public function __construct(Connection $connection)
|
||||
|
@@ -49,23 +49,23 @@ class dibi
|
||||
ASC = 'ASC',
|
||||
DESC = 'DESC';
|
||||
|
||||
/** @var string|null Last SQL command @see dibi::query() */
|
||||
public static $sql;
|
||||
/** Last SQL command @see dibi::query() */
|
||||
public static ?string $sql = null;
|
||||
|
||||
/** @var float|null Elapsed time for last query */
|
||||
public static $elapsedTime;
|
||||
/** Elapsed time for last query */
|
||||
public static ?float $elapsedTime = null;
|
||||
|
||||
/** @var float Elapsed time for all queries */
|
||||
public static $totalTime;
|
||||
/** Elapsed time for all queries */
|
||||
public static float $totalTime = 0;
|
||||
|
||||
/** @var int Number or queries */
|
||||
public static $numOfQueries = 0;
|
||||
/** Number or queries */
|
||||
public static int $numOfQueries = 0;
|
||||
|
||||
/** @var Dibi\Connection[] Connection registry storage for Dibi\Connection objects */
|
||||
private static $registry = [];
|
||||
private static array $registry = [];
|
||||
|
||||
/** @var Dibi\Connection Current connection */
|
||||
private static $connection;
|
||||
/** Current connection */
|
||||
private static Dibi\Connection $connection;
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -15,8 +15,7 @@ namespace Dibi;
|
||||
*/
|
||||
class Exception extends \Exception
|
||||
{
|
||||
/** @var string|null */
|
||||
private $sql;
|
||||
private ?string $sql;
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,8 +85,7 @@ class NotSupportedException extends Exception
|
||||
*/
|
||||
class ProcedureException extends Exception
|
||||
{
|
||||
/** @var string */
|
||||
protected $severity;
|
||||
protected string $severity;
|
||||
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user