Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ColumnInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ interface ColumnInterface
/**
* PHP types for phpType() method.
*/
public const INT = 'int';
public const BOOL = 'bool';
public const INT = 'int';
public const BOOL = 'bool';
public const STRING = 'string';
public const FLOAT = 'float';
public const FLOAT = 'float';

/**
* Get element name (unquoted).
Expand Down
17 changes: 11 additions & 6 deletions src/Config/DatabaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ final class DatabaseConfig extends InjectableConfig
{
use AliasTrait;

public const CONFIG = 'database';
public const CONFIG = 'database';
public const DEFAULT_DATABASE = 'default';

/**
* @internal
*
* @var array
*/
protected $config = [
'default' => self::DEFAULT_DATABASE,
'aliases' => [],
'databases' => [],
'default' => self::DEFAULT_DATABASE,
'aliases' => [],
'databases' => [],
'connections' => [],
];

Expand Down Expand Up @@ -74,6 +75,7 @@ public function getDrivers(): array

/**
* @param string $database
*
* @return bool
*/
public function hasDatabase(string $database): bool
Expand All @@ -83,9 +85,10 @@ public function hasDatabase(string $database): bool

/**
* @param string $database
* @return DatabasePartial
*
* @throws ConfigException
*
* @return DatabasePartial
*/
public function getDatabase(string $database): DatabasePartial
{
Expand All @@ -105,6 +108,7 @@ public function getDatabase(string $database): DatabasePartial

/**
* @param string $driver
*
* @return bool
*/
public function hasDriver(string $driver): bool
Expand All @@ -114,9 +118,10 @@ public function hasDriver(string $driver): bool

/**
* @param string $driver
* @return Autowire
*
* @throws ConfigException
*
* @return Autowire
*/
public function getDriver(string $driver): Autowire
{
Expand Down
4 changes: 2 additions & 2 deletions src/Config/DatabasePartial.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class DatabasePartial
/** @var string */
private $driver;

/** @var null|string */
/** @var string|null */
private $readDriver;

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ public function getDriver(): string
}

/**
* @return null|string
* @return string|null
*/
public function getReadDriver(): ?string
{
Expand Down
7 changes: 4 additions & 3 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ final class Database implements DatabaseInterface, InjectableInterface
public const INJECTOR = DatabaseManager::class;

// Isolation levels for transactions
public const ISOLATION_SERIALIZABLE = DriverInterface::ISOLATION_SERIALIZABLE;
public const ISOLATION_REPEATABLE_READ = DriverInterface::ISOLATION_REPEATABLE_READ;
public const ISOLATION_READ_COMMITTED = DriverInterface::ISOLATION_READ_COMMITTED;
public const ISOLATION_SERIALIZABLE = DriverInterface::ISOLATION_SERIALIZABLE;
public const ISOLATION_REPEATABLE_READ = DriverInterface::ISOLATION_REPEATABLE_READ;
public const ISOLATION_READ_COMMITTED = DriverInterface::ISOLATION_READ_COMMITTED;
public const ISOLATION_READ_UNCOMMITTED = DriverInterface::ISOLATION_READ_UNCOMMITTED;

/** @var string */
Expand Down Expand Up @@ -68,6 +68,7 @@ public function __construct(
* Shortcut to get table abstraction.
*
* @param string $name Table name without prefix.
*
* @return Table
*/
public function __get(string $name): Table
Expand Down
24 changes: 19 additions & 5 deletions src/DatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface DatabaseInterface
{
// Driver types
public const WRITE = 0;
public const READ = 1;
public const READ = 1;

/**
* @return string
Expand All @@ -44,6 +44,7 @@ public function getType(): string;

/**
* @param int $type
*
* @return DriverInterface
*/
public function getDriver(int $type = self::WRITE): DriverInterface;
Expand All @@ -53,7 +54,8 @@ public function getDriver(int $type = self::WRITE): DriverInterface;
*
* @param string $prefix
* @param bool $add
* @return self|$this
*
* @return $this|self
*/
public function withPrefix(string $prefix, bool $add = true): self;

Expand All @@ -66,6 +68,7 @@ public function getPrefix(): string;
* Check if table exists.
*
* @param string $name
*
* @return bool
*/
public function hasTable(string $name): bool;
Expand All @@ -79,6 +82,7 @@ public function getTables(): array;

/**
* @param string $name
*
* @return TableInterface
*/
public function table(string $name): TableInterface;
Expand All @@ -88,9 +92,10 @@ public function table(string $name): TableInterface;
*
* @param string $query
* @param array $parameters Parameters to be binded into query.
* @return int
*
* @throws StatementException
*
* @return int
*/
public function execute(string $query, array $parameters = []): int;

Expand All @@ -99,16 +104,18 @@ public function execute(string $query, array $parameters = []): int;
*
* @param string $query
* @param array $parameters Parameters to be binded into query.
* @return StatementInterface
*
* @throws StatementException
*
* @return StatementInterface
*/
public function query(string $query, array $parameters = []): StatementInterface;

/**
* Get instance of InsertBuilder associated with current Database.
*
* @param string $table Table where values should be inserted to.
*
* @return InsertQuery
*/
public function insert(string $table = ''): InsertQuery;
Expand All @@ -119,6 +126,7 @@ public function insert(string $table = ''): InsertQuery;
* @param string $table Table where rows should be updated in.
* @param array $values Initial set of columns to update associated with their values.
* @param array $where Initial set of where rules specified as array.
*
* @return UpdateQuery
*/
public function update(string $table = '', array $values = [], array $where = []): UpdateQuery;
Expand All @@ -128,6 +136,7 @@ public function update(string $table = '', array $values = [], array $where = []
*
* @param string $table Table where rows should be deleted from.
* @param array $where Initial set of where rules specified as array.
*
* @return DeleteQuery
*/
public function delete(string $table = '', array $where = []): DeleteQuery;
Expand All @@ -136,6 +145,7 @@ public function delete(string $table = '', array $where = []): DeleteQuery;
* Get instance of SelectBuilder associated with current Database.
*
* @param array|string $columns Columns to select.
*
* @return SelectQuery
*/
public function select($columns = '*'): SelectQuery;
Expand All @@ -145,19 +155,23 @@ public function select($columns = '*'): SelectQuery;
* function must receive only one argument - DatabaseInterface instance.
*
* @link http://en.wikipedia.org/wiki/Database_transaction
*
* @param callable $callback
* @param string $isolationLevel
* @return mixed
*
* @throws \Throwable
*
* @return mixed
*/
public function transaction(callable $callback, string $isolationLevel = null);

/**
* Start database transaction.
*
* @link http://en.wikipedia.org/wiki/Database_transaction
*
* @param string $isolationLevel
*
* @return bool
*/
public function begin(string $isolationLevel = null): bool;
Expand Down
22 changes: 13 additions & 9 deletions src/DatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ public function createInjection(\ReflectionClass $class, string $context = null)
/**
* Get all databases.
*
* @return Database[]
*
* @throws DatabaseException
*
* @return Database[]
*/
public function getDatabases(): array
{
Expand All @@ -167,9 +167,10 @@ public function getDatabases(): array
* Get Database associated with a given database alias or automatically created one.
*
* @param string|null $database
* @return Database|DatabaseInterface
*
* @throws DBALException
*
* @return Database|DatabaseInterface
*/
public function database(string $database = null): DatabaseInterface
{
Expand Down Expand Up @@ -214,9 +215,9 @@ public function addDatabase(Database $database): void
/**
* Get instance of every available driver/connection.
*
* @return Driver[]
*
* @throws DBALException
*
* @return Driver[]
*/
public function getDrivers(): array
{
Expand All @@ -239,9 +240,10 @@ public function getDrivers(): array
* Get driver instance by it's name or automatically create one.
*
* @param string $driver
* @return DriverInterface
*
* @throws DBALException
*
* @return DriverInterface
*/
public function driver(string $driver): DriverInterface
{
Expand Down Expand Up @@ -271,11 +273,12 @@ public function driver(string $driver): DriverInterface
*
* @param string $name
* @param DriverInterface $driver
* @return self
*
* @throws DBALException
*
* @return self
*/
public function addDriver(string $name, DriverInterface $driver): DatabaseManager
public function addDriver(string $name, DriverInterface $driver): self
{
if (isset($this->drivers[$name])) {
throw new DBALException("Connection '{$name}' already exists");
Expand All @@ -288,9 +291,10 @@ public function addDriver(string $name, DriverInterface $driver): DatabaseManage

/**
* @param DatabasePartial $database
* @return Database
*
* @throws DBALException
*
* @return Database
*/
protected function makeDatabase(DatabasePartial $database): Database
{
Expand Down
3 changes: 2 additions & 1 deletion src/DatabaseProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ interface DatabaseProviderInterface
* Get Database associated with a given database alias or automatically created one.
*
* @param string|null $database
* @return DatabaseInterface
*
* @throws DBALException
*
* @return DatabaseInterface
*/
public function database(string $database = null): DatabaseInterface;
}
1 change: 1 addition & 0 deletions src/Driver/CachingCompilerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface CachingCompilerInterface extends CompilerInterface
*
* @param QueryParameters $params
* @param array $tokens
*
* @return string
*/
public function hashLimit(QueryParameters $params, array $tokens): string;
Expand Down
Loading