Skip to content

Commit

Permalink
Fix PHP 8.4 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-redfern committed Nov 28, 2024
1 parent 9fc1f57 commit 58f2101
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2']
php-version: ['8.1', '8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v2
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Change Log
==========

2024-11-28
----------

* fix PHP 8.4 deprecations
* fix arg names to be more consistent with the definition

2024-03-03
----------

* fix incorrect event property access
* fix arg names to be more consistent with the definition
* update to DBAL 4

2023-05-03
----------

Expand Down
10 changes: 5 additions & 5 deletions src/Query/Expressions/FromExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
*/
class FromExpression extends ExpressionSet
{
public function add(Expression|string $table, string $as = null): self
public function add(Expression|string $expression, ?string $as = null): self
{
if ($table instanceof Query && is_null($as)) {
if ($expression instanceof Query && is_null($as)) {
throw QueryException::fromQueryRequiresAlias();
}
if (is_string($table)) {
$table = new IdentifierExpression($table);
if (is_string($expression)) {
$expression = new IdentifierExpression($expression);
}

$this->expressions[] = new TableClauseExpression($table, $as);
$this->expressions[] = new TableClauseExpression($expression, $as);

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Expressions/InsertClauseExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class InsertClauseExpression implements Expression
protected ModifierExpression $modifier;
protected array $columns;

public function __construct(Expression|string $table = null, array $columns = [])
public function __construct(Expression|string|null $table = null, array $columns = [])
{
$this->table = $table ?? '';
$this->columns = $columns;
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Expressions/OrderByExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OrderByExpression extends QueryExpression
*/
public function __construct(
Expression|array|string $conditions = [],
TypeMap $types = null,
?TypeMap $types = null,
string $conjunction = ''
) {
parent::__construct($conditions, $types, $conjunction);
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Expressions/QueryExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class QueryExpression implements Expression, Countable
*/
public function __construct(
Expression|array|string $conditions = [],
TypeMap $types = null,
?TypeMap $types = null,
string $conjunction = 'AND'
)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Expressions/SelectClauseExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SelectClauseExpression implements Expression
private DistinctExpression $distinct;
private ModifierExpression $modifier;

public function __construct(FieldExpression $fields = null, DistinctExpression $distinct = null, ModifierExpression $modifier = null)
public function __construct(?FieldExpression $fields = null, ?DistinctExpression $distinct = null, ?ModifierExpression $modifier = null)
{
$this->fields = $fields ?? new FieldExpression();
$this->distinct = $distinct ?? new DistinctExpression();
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Expressions/UpdateClauseExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class UpdateClauseExpression implements Expression
protected Expression|string $table;
protected ModifierExpression $modifier;

public function __construct(Expression|string $table = null, ModifierExpression $modifier = null)
public function __construct(Expression|string|null $table = null, ?ModifierExpression $modifier = null)
{
$this->table = $table ?? '';
$this->modifier = $modifier ?? new ModifierExpression();
Expand Down
4 changes: 2 additions & 2 deletions src/Query/Expressions/WithExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
class WithExpression extends ExpressionSet
{
public function add(CommonTableExpression $cte): self
public function add(CommonTableExpression $expression): self
{
$this->expressions[] = $cte;
$this->expressions[] = $expression;

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public function modifier(Expression|string ...$modifiers): static
*
* @return $this
*/
public function from(Expression|string $table, string $as = null): static
public function from(Expression|string $table, ?string $as = null): static
{
$from = $this->parts[self::FROM] ??= new FromExpression();
$from->add($table, $as);
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
function select(
Expression|Closure|array|string|float|int $fields = [],
Expression|string $from = null,
Expression|string|null $from = null,
array $types = []
): SelectQuery
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/QueryCompilerBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function buildCompiler(array $compilers = [], array $events = []): Com
return $this->buildDelegatingCompiler($this->buildEventDispatcher($events), $compilers);
}

protected function buildDelegatingCompiler(EventDispatcherInterface $evt = null, array $compilers = []): DelegatingSqlCompiler
protected function buildDelegatingCompiler(?EventDispatcherInterface $evt = null, array $compilers = []): DelegatingSqlCompiler
{
if (empty($compilers)) {
$compilers = [
Expand Down

0 comments on commit 58f2101

Please sign in to comment.