Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve compatibility with PHP 8.4 #214

Merged
merged 2 commits into from
Dec 10, 2024
Merged
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
652 changes: 340 additions & 312 deletions composer.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ public function query(string $query, array $parameters = []): StatementInterface
->query($query, $parameters);
}

public function insert(string $table = null): InsertQuery
public function insert(?string $table = null): InsertQuery
{
return $this->getDriver(self::WRITE)
->getQueryBuilder()
->insertQuery($this->prefix, $table);
}

public function update(string $table = null, array $values = [], array $where = []): UpdateQuery
public function update(?string $table = null, array $values = [], array $where = []): UpdateQuery
{
return $this->getDriver(self::WRITE)
->getQueryBuilder()
->updateQuery($this->prefix, $table, $where, $values);
}

public function delete(string $table = null, array $where = []): DeleteQuery
public function delete(?string $table = null, array $where = []): DeleteQuery
{
return $this->getDriver(self::WRITE)
->getQueryBuilder()
Expand All @@ -168,7 +168,7 @@ public function select(mixed $columns = '*'): SelectQuery

public function transaction(
callable $callback,
string $isolationLevel = null,
?string $isolationLevel = null,
): mixed {
$this->begin($isolationLevel);

Expand All @@ -183,7 +183,7 @@ public function transaction(
}
}

public function begin(string $isolationLevel = null): bool
public function begin(?string $isolationLevel = null): bool
{
return $this->getDriver(self::WRITE)->beginTransaction($isolationLevel);
}
Expand Down
4 changes: 2 additions & 2 deletions src/DatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ public function select(mixed $columns = '*'): SelectQuery;
* @throws \Throwable
*
*/
public function transaction(callable $callback, string $isolationLevel = null): mixed;
public function transaction(callable $callback, ?string $isolationLevel = null): mixed;

/**
* Start database transaction.
*
* @link http://en.wikipedia.org/wiki/Database_transaction
*/
public function begin(string $isolationLevel = null): bool;
public function begin(?string $isolationLevel = null): bool;

/**
* Commit the active database transaction.
Expand Down
2 changes: 1 addition & 1 deletion src/DatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getDatabases(): array
*
* @throws DBALException
*/
public function database(string $database = null): DatabaseInterface
public function database(?string $database = null): DatabaseInterface
{
if ($database === null) {
$database = $this->config->getDefaultDatabase();
Expand Down
2 changes: 1 addition & 1 deletion src/DatabaseProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface DatabaseProviderInterface
* @throws DBALException
*
*/
public function database(string $database = null): DatabaseInterface;
public function database(?string $database = null): DatabaseInterface;
}
4 changes: 2 additions & 2 deletions src/Driver/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ protected function groupBy(QueryParameters $params, Quoter $q, array $groupBy):
abstract protected function limit(
QueryParameters $params,
Quoter $q,
int $limit = null,
int $offset = null,
?int $limit = null,
?int $offset = null,
): string;

protected function updateQuery(
Expand Down
4 changes: 2 additions & 2 deletions src/Driver/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function execute(string $query, array $parameters = []): int
*
* @return mixed
*/
public function lastInsertID(string $sequence = null)
public function lastInsertID(?string $sequence = null)
{
$result = $this->getPDO()->lastInsertId();
$this->logger?->debug("Insert ID: {$result}");
Expand All @@ -256,7 +256,7 @@ public function getTransactionLevel(): int
* @link http://en.wikipedia.org/wiki/Isolation_(database_systems)
*
*/
public function beginTransaction(string $isolationLevel = null): bool
public function beginTransaction(?string $isolationLevel = null): bool
{
++$this->transactionLevel;

Expand Down
4 changes: 2 additions & 2 deletions src/Driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function execute(string $query, array $parameters = []): int;
*
* @return mixed
*/
public function lastInsertID(string $sequence = null);
public function lastInsertID(?string $sequence = null);

/**
* Start SQL transaction with specified isolation level (not all DBMS support it). Nested
Expand All @@ -187,7 +187,7 @@ public function lastInsertID(string $sequence = null);
*
* @return bool True of success.
*/
public function beginTransaction(string $isolationLevel = null): bool;
public function beginTransaction(?string $isolationLevel = null): bool;

/**
* Commit the active database transaction.
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/HandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function hasTable(string $table): bool;
* @throws HandlerException
*
*/
public function getSchema(string $table, string $prefix = null): AbstractTable;
public function getSchema(string $table, ?string $prefix = null): AbstractTable;

/**
* Create table based on a given schema.
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/MySQL/MySQLCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function insertQuery(QueryParameters $params, Quoter $q, array $tokens
*
* @link http://dev.mysql.com/doc/refman/5.0/en/select.html#id4651990
*/
protected function limit(QueryParameters $params, Quoter $q, int $limit = null, int $offset = null): string
protected function limit(QueryParameters $params, Quoter $q, ?int $limit = null, ?int $offset = null): string
{
if ($limit === null && $offset === null) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/MySQL/MySQLHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MySQLHandler extends Handler
/**
* @psalm-param non-empty-string $table
*/
public function getSchema(string $table, string $prefix = null): AbstractTable
public function getSchema(string $table, ?string $prefix = null): AbstractTable
{
return new MySQLTable($this->driver, $table, $prefix ?? '');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/MySQL/Schema/MySQLColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class MySQLColumn extends AbstractColumn
/**
* @psalm-param non-empty-string $table
*/
public static function createInstance(string $table, array $schema, \DateTimeZone $timezone = null): self
public static function createInstance(string $table, array $schema, ?\DateTimeZone $timezone = null): self
{
$column = new self($table, $schema['Field'], $timezone);

Expand Down
4 changes: 2 additions & 2 deletions src/Driver/PDOStatementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public function bindParam(
int|string $param,
mixed &$var,
int $type = \PDO::PARAM_STR,
int $maxLength = null,
?int $maxLength = null,
mixed $driverOptions = null,
): bool;

public function bindColumn(
int|string $column,
mixed &$var,
int $type = \PDO::PARAM_STR,
int $maxLength = null,
?int $maxLength = null,
mixed $driverOptions = null,
): bool;

Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Postgres/PostgresCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function distinct(QueryParameters $params, Quoter $q, string|bool|arra
return 'DISTINCT';
}

protected function limit(QueryParameters $params, Quoter $q, int $limit = null, int $offset = null): string
protected function limit(QueryParameters $params, Quoter $q, ?int $limit = null, ?int $offset = null): string
{
if ($limit === null && $offset === null) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Postgres/PostgresDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function resetPrimaryKeys(): void
*
*
*/
public function beginTransaction(string $isolationLevel = null): bool
public function beginTransaction(?string $isolationLevel = null): bool
{
++$this->transactionLevel;

Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Postgres/PostgresHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PostgresHandler extends Handler
/**
* @psalm-param non-empty-string $table
*/
public function getSchema(string $table, string $prefix = null): AbstractTable
public function getSchema(string $table, ?string $prefix = null): AbstractTable
{
return new PostgresTable($this->driver, $table, $prefix ?? '');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Postgres/Query/PostgresInsertQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PostgresInsertQuery extends InsertQuery implements ReturningInterface
/** @var list<FragmentInterface|non-empty-string> */
protected array $returningColumns = [];

public function withDriver(DriverInterface $driver, string $prefix = null): QueryInterface
public function withDriver(DriverInterface $driver, ?string $prefix = null): QueryInterface
{
$driver instanceof PostgresDriver or throw new BuilderException(
'Postgres InsertQuery can be used only with Postgres driver',
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/ReadonlyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/**
* @psalm-param non-empty-string $table
*/
public function getSchema(string $table, string $prefix = null): AbstractTable
public function getSchema(string $table, ?string $prefix = null): AbstractTable

Check warning on line 49 in src/Driver/ReadonlyHandler.php

View check run for this annotation

Codecov / codecov/patch

src/Driver/ReadonlyHandler.php#L49

Added line #L49 was not covered by tests
{
return $this->parent->getSchema($table, $prefix);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLServer/Query/SQLServerInsertQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SQLServerInsertQuery extends InsertQuery implements ReturningInterface
*/
protected array $returningColumns = [];

public function withDriver(DriverInterface $driver, string $prefix = null): QueryInterface
public function withDriver(DriverInterface $driver, ?string $prefix = null): QueryInterface
{
$driver instanceof SQLServerDriver or throw new BuilderException(
'SQLServer InsertQuery can be used only with SQLServer driver',
Expand Down
6 changes: 3 additions & 3 deletions src/Driver/SQLServer/SQLServerCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ protected function selectQuery(QueryParameters $params, Quoter $q, array $tokens
protected function limit(
QueryParameters $params,
Quoter $q,
int $limit = null,
int $offset = null,
string $rowNumber = null,
?int $limit = null,
?int $offset = null,
?string $rowNumber = null,
): string {
if ($limit === null && $offset === null) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLServer/SQLServerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SQLServerHandler extends Handler
/**
* @psalm-param non-empty-string $table
*/
public function getSchema(string $table, string $prefix = null): AbstractTable
public function getSchema(string $table, ?string $prefix = null): AbstractTable
{
return new SQLServerTable($this->driver, $table, $prefix ?? '');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLite/SQLiteCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SQLiteCompiler extends Compiler implements CachingCompilerInterface
*
* @link http://stackoverflow.com/questions/10491492/sqllite-with-skip-offset-only-not-limit
*/
protected function limit(QueryParameters $params, Quoter $q, int $limit = null, int $offset = null): string
protected function limit(QueryParameters $params, Quoter $q, ?int $limit = null, ?int $offset = null): string
{
if ($limit === null && $offset === null) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLite/SQLiteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function hasTable(string $table): bool
return (bool) $this->driver->query($query, [$table])->fetchColumn();
}

public function getSchema(string $table, string $prefix = null): AbstractTable
public function getSchema(string $table, ?string $prefix = null): AbstractTable
{
return new SQLiteTable($this->driver, $table, $prefix ?? '');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLite/Schema/SQLiteColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class SQLiteColumn extends AbstractColumn
public static function createInstance(
string $table,
array $schema,
\DateTimeZone $timezone = null,
?\DateTimeZone $timezone = null,
): self {
$column = new self($table, $schema['name'], $timezone);

Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function fetch(int $mode = self::FETCH_ASSOC): mixed
return $this->pdoStatement->fetch($mode);
}

public function fetchColumn(int $columnNumber = null): mixed
public function fetchColumn(?int $columnNumber = null): mixed
{
return $columnNumber === null
? $this->pdoStatement->fetchColumn()
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ReadonlyConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ReadonlyConnectionException extends DBALException
*
* @return static
*/
public static function onWriteStatementExecution(int $code = 0, \Throwable $prev = null): self
public static function onWriteStatementExecution(int $code = 0, ?\Throwable $prev = null): self
{
return new self(self::WRITE_STMT_MESSAGE, $code, $prev);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LoggerFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

interface LoggerFactoryInterface
{
public function getLogger(DriverInterface $driver = null): LoggerInterface;
public function getLogger(?DriverInterface $driver = null): LoggerInterface;
}
4 changes: 2 additions & 2 deletions src/Query/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class ActiveQuery implements QueryInterface, \Stringable
protected ?DriverInterface $driver = null;
protected ?string $prefix = null;

public function withDriver(DriverInterface $driver, string $prefix = null): QueryInterface
public function withDriver(DriverInterface $driver, ?string $prefix = null): QueryInterface
{
$query = clone $this;
$query->driver = $driver;
Expand All @@ -50,7 +50,7 @@ public function getPrefix(): ?string
*
* @psalm-return non-empty-string
*/
public function sqlStatement(QueryParameters $parameters = null): string
public function sqlStatement(?QueryParameters $parameters = null): string
{
$this->driver === null and throw new BuilderException('Unable to build query without associated driver');

Expand Down
6 changes: 3 additions & 3 deletions src/Query/BuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function withDriver(DriverInterface $driver): self;
*/
public function insertQuery(
string $prefix,
string $table = null,
?string $table = null,
): InsertQuery;

/**
Expand All @@ -45,7 +45,7 @@ public function selectQuery(

public function deleteQuery(
string $prefix,
string $from = null,
?string $from = null,
array $where = [],
): DeleteQuery;

Expand All @@ -55,7 +55,7 @@ public function deleteQuery(
*/
public function updateQuery(
string $prefix,
string $table = null,
?string $table = null,
array $where = [],
array $values = [],
): UpdateQuery;
Expand Down
2 changes: 1 addition & 1 deletion src/Query/InsertQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InsertQuery extends ActiveQuery
protected array $columns = [];
protected array $values = [];

public function __construct(string $table = null)
public function __construct(?string $table = null)
{
$this->table = $table ?? '';
}
Expand Down
6 changes: 3 additions & 3 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function withDriver(DriverInterface $driver): BuilderInterface
*/
public function insertQuery(
string $prefix,
string $table = null,
?string $table = null,
): InsertQuery {
$insert = $this->insertQuery->withDriver($this->driver, $prefix);

Expand Down Expand Up @@ -80,7 +80,7 @@ public function selectQuery(

public function deleteQuery(
string $prefix,
string $from = null,
?string $from = null,
array $where = [],
): DeleteQuery {
$delete = $this->deleteQuery->withDriver($this->driver, $prefix);
Expand All @@ -97,7 +97,7 @@ public function deleteQuery(
*/
public function updateQuery(
string $prefix,
string $table = null,
?string $table = null,
array $where = [],
array $values = [],
): UpdateQuery {
Expand Down
2 changes: 1 addition & 1 deletion src/Query/QueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface QueryInterface extends FragmentInterface
*
* @return $this
*/
public function withDriver(DriverInterface $driver, string $prefix = null): self;
public function withDriver(DriverInterface $driver, ?string $prefix = null): self;

public function getDriver(): ?DriverInterface;

Expand Down
Loading
Loading