Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Jul 5, 2022
1 parent 5f4b60b commit 32ef32a
Show file tree
Hide file tree
Showing 98 changed files with 1,053 additions and 832 deletions.
6 changes: 3 additions & 3 deletions src/ColumnInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,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 @@ -21,17 +21,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 @@ -75,6 +76,7 @@ public function getDrivers(): array

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

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

/**
* @param string $driver
*
* @return bool
*/
public function hasDriver(string $driver): bool
Expand All @@ -115,9 +119,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 @@ -24,7 +24,7 @@ final class DatabasePartial
/** @var string */
private $driver;

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

/**
Expand Down Expand Up @@ -70,7 +70,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 @@ -32,9 +32,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 @@ -72,6 +72,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 @@ -28,7 +28,7 @@ interface DatabaseInterface
{
// Driver types
public const WRITE = 0;
public const READ = 1;
public const READ = 1;

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

/**
* @param int $type
*
* @return DriverInterface
*/
public function getDriver(int $type = self::WRITE): DriverInterface;
Expand All @@ -54,7 +55,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 @@ -67,6 +69,7 @@ public function getPrefix(): string;
* Check if table exists.
*
* @param string $name
*
* @return bool
*/
public function hasTable(string $name): bool;
Expand All @@ -80,6 +83,7 @@ public function getTables(): array;

/**
* @param string $name
*
* @return TableInterface
*/
public function table(string $name): TableInterface;
Expand All @@ -89,9 +93,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 @@ -100,16 +105,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 @@ -120,6 +127,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 @@ -129,6 +137,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 @@ -137,6 +146,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 @@ -146,19 +156,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 @@ -154,9 +154,9 @@ public function createInjection(\ReflectionClass $class, string $context = null)
/**
* Get all databases.
*
* @return Database[]
*
* @throws DatabaseException
*
* @return Database[]
*/
public function getDatabases(): array
{
Expand All @@ -179,9 +179,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 @@ -227,9 +228,9 @@ public function addDatabase(SpiralDatabase $database): void
/**
* Get instance of every available driver/connection.
*
* @return Driver[]
*
* @throws DBALException
*
* @return Driver[]
*/
public function getDrivers(): array
{
Expand All @@ -252,9 +253,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 @@ -284,11 +286,12 @@ public function driver(string $driver): DriverInterface
*
* @param string $name
* @param DriverInterface $driver
* @return self
*
* @throws DBALException
*
* @return self
*/
public function addDriver(string $name, SpiralDriverInterface $driver): DatabaseManager
public function addDriver(string $name, SpiralDriverInterface $driver): self
{
if (isset($this->drivers[$name])) {
throw new DBALException("Connection '{$name}' already exists");
Expand All @@ -301,9 +304,10 @@ public function addDriver(string $name, SpiralDriverInterface $driver): Database

/**
* @param DatabasePartial $database
* @return Database
*
* @throws DBALException
*
* @return Database
*/
protected function makeDatabase(SpiralDatabasePartial $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 @@ -20,9 +20,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;
}
Expand Down
1 change: 1 addition & 0 deletions src/Driver/CachingCompilerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface CachingCompilerInterface extends CompilerInterface
*
* @param QueryParameters $params
* @param array $tokens
*
* @return string
*/
public function hashLimit(SpiralQueryParameters $params, array $tokens): string;
Expand Down
Loading

0 comments on commit 32ef32a

Please sign in to comment.