Skip to content

Fix implicitly nullable parameters deprecated in PHP 8.4 - #165

Open
peterschade wants to merge 1 commit into
skipperbent:v4-releasefrom
peterschade:fix/php84-nullable-parameters
Open

Fix implicitly nullable parameters deprecated in PHP 8.4#165
peterschade wants to merge 1 commit into
skipperbent:v4-releasefrom
peterschade:fix/php84-nullable-parameters

Conversation

@peterschade

Copy link
Copy Markdown

Summary

PHP 8.4 deprecates implicitly nullable parameters — a typed parameter with a null default (e.g. Connection $connection = null) now emits:

Implicitly marking parameter $connection as nullable is deprecated, the explicit nullable type must be used instead

This surfaces as a runtime deprecation notice the moment a QueryBuilderHandler is constructed (and in several other call paths). This PR marks every such parameter explicitly nullable (?Type).

Changes

Explicit ? added to these signatures:

  • QueryBuilderHandler::__construct(?Connection $connection = null)
  • QueryBuilderHandler::delete(?array $columns = null)
  • QueryBuilderHandler::getEvent(string $name, ?string $table = null)
  • Exception::__construct(..., ?Throwable $previous = null, ?QueryObject $query = null)
  • Exception::create(\Exception $e, ?string $adapterName = null, ?QueryObject $query = null)
  • BaseAdapter::delete(array $statements, ?array $columns = null)
  • Sqlserver::delete(array $statements, ?array $columns = null)
  • NestedCriteria::whereHandler($key, ?string $operator = null, ...)

Notes

  • Behavior is unchanged — these parameters were already nullable at runtime; the fix only makes the type declaration explicit, silencing the deprecation.
  • Fully backwards compatible: ?Type is valid syntax since PHP 7.1, and the library already requires PHP >= 7.1.
  • Test suite passes on PHP 8.5 with no deprecation notices.

Explicitly mark nullable parameters (`?Type`) instead of relying on the
implicit nullability of a typed parameter with a `null` default, which is
deprecated as of PHP 8.4 and emits a deprecation notice at runtime.

Affected signatures:
- QueryBuilderHandler::__construct(), delete(), getEvent()
- Exception::__construct(), create()
- BaseAdapter::delete()
- Sqlserver::delete()
- NestedCriteria::whereHandler()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant