Skip to content

Commit

Permalink
explicit nullable types: fix deprecation notices in PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mindplay-dk committed Oct 27, 2024
1 parent 0d72a27 commit 224b5aa
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/exceptions/SQLException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
array $params = [],
string $message = 'SQL Error',
int $code = 0,
Exception $previous = null
Exception|null $previous = null
) {
parent::__construct(
"{$message}\n" . QueryFormatter::formatQuery($sql, $params),
Expand Down
2 changes: 1 addition & 1 deletion src/framework/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function transact(callable $func): bool;
*
* @return string|int|null the last auto-generated ID (usually an integer, could be a string for UUIDs, etc.)
*/
public function lastInsertId(?string $sequence_name = null): string|int|null;
public function lastInsertId(string|null $sequence_name = null): string|int|null;

/**
* Add a `Logger` instance, which will be notified when a query is executed.
Expand Down
2 changes: 1 addition & 1 deletion src/framework/pdo/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private function expandPlaceholders(string $sql, array $params): string
/**
* @param $sequence_name auto-sequence name (or NULL for e.g. MySQL which supports only one auto-key)
*/
public function lastInsertId(?string $sequence_name = null): string|int|null
public function lastInsertId(string|null $sequence_name = null): string|int|null
{
$id = $this->pdo->lastInsertId($sequence_name);

Expand Down
2 changes: 1 addition & 1 deletion src/framework/pdo/PDOProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PDOProvider
* @param string|null $host optional hostname; defaults to "localhost"
* @param int|null $port optional port-number; defaults to the standard port-number for the given $db type
*/
public function __construct(string $protocol, string $dbname, string $username, string $password, array $options = null, string $host = null, int|null $port = null)
public function __construct(string $protocol, string $dbname, string $username, string $password, array|null $options = null, string|null $host = null, int|null $port = null)
{
static $default_port = [
self::PROTOCOL_MYSQL => 3306,
Expand Down
2 changes: 1 addition & 1 deletion src/model/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class Database
*
* @param DatabaseContainerFactory|null $factory custom factory instance (typically omitted)
*/
public function __construct(DatabaseContainerFactory $factory = null)
public function __construct(DatabaseContainerFactory|null $factory = null)
{
if ($factory === null) {
$factory = new DatabaseContainerFactory();
Expand Down
2 changes: 1 addition & 1 deletion src/model/components/Returning.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function returningColumns($cols): static
*
* @return $this
*/
public function returningValue($expr, $name = null, $type = null): static
public function returningValue(string $expr, string|null $name = null, Type|string|null $type = null): static
{
$this->return_vars->addValue($expr, $name, $type);

Expand Down
2 changes: 1 addition & 1 deletion src/model/query/SelectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function columns(Column|array $cols)
*
* @return $this
*/
public function value($expr, $name = null, $type = null)
public function value(string $expr, string|null $name = null, Type|string|null $type = null)
{
$this->return_vars->addValue($expr, $name, $type);

Expand Down
2 changes: 1 addition & 1 deletion test/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function normalize_sql($sql)
* @param string $expected_sql
* @param string|null $why
*/
function sql_eq(Statement $query, $expected_sql, $why = null)
function sql_eq(Statement $query, $expected_sql, string|null $why = null)
{
$actual = normalize_sql($query->getSQL());
$expected = normalize_sql($expected_sql);
Expand Down

0 comments on commit 224b5aa

Please sign in to comment.