Skip to content

fix: make all implicitly-nullable parameters explicit (PHP 8.4 deprecation) - #7

Merged
struzik-vladislav merged 2 commits into
struzik-vladislav:masterfrom
kiuka:fix/login-setnewpassword-implicit-nullable
Aug 9, 2026
Merged

fix: make all implicitly-nullable parameters explicit (PHP 8.4 deprecation)#7
struzik-vladislav merged 2 commits into
struzik-vladislav:masterfrom
kiuka:fix/login-setnewpassword-implicit-nullable

Conversation

@kiuka

@kiuka kiuka commented Jul 30, 2026

Copy link
Copy Markdown

Problem

Several methods declare a typed parameter with a null default but no explicit ? — relying on the implicit conversion to a nullable type. PHP 8.4 deprecates this (E_DEPRECATED), emitted when the declaration is loaded (not when the method is called), so consumers on PHP ≥ 8.4 get, e.g.:

Struzik\EPPClient\Response\ResponseInterface::get(): Implicitly marking parameter $contextNode as nullable is deprecated, the explicit nullable type must be used instead

Fix

Make every implicitly-nullable parameter in src/ explicit. There are four, all covered by this PR:

Location Before After
Request/Session/LoginRequest::setNewPassword() string $newPassword = null ?string
Request/Contact/UpdateContactRequest::setDisclose() Disclose $disclose = null ?Disclose
Response/ResponseInterface::get() \DOMNode $contextNode = null ?\DOMNode
Response/ResponseInterface::getFirst() \DOMNode $contextNode = null ?\DOMNode

After this, no implicitly-nullable parameters remain in src/.

Why the ResponseInterface ones matter in practice

Because the deprecation fires when the interface is loaded, it's not just cosmetic. Any consumer that parses EPP responses inside an error-to-exception handler has the notice promoted to a fatal error. Concretely, struzik-vladislav/epp-socket-connection wraps its socket IO in an E_ALL error handler (to turn socket/TLS warnings into exceptions); on PHP 8.4+ this implicit-nullable deprecation is raised while reading the server greeting and surfaces as ConnectionException: Can not open connection to the EPP server — i.e. every EPP connection breaks. AbstractResponse already uses ?\DOMNode, so the interface was also inconsistent with its own implementation.

Compatibility

?Type is valid on the full supported range (php: ^7.4|^8.0); behaviour is unchanged. No test changes required.

Balazs Kiraly added 2 commits July 30, 2026 10:54
`setNewPassword(string $newPassword = null)` relies on the implicit
conversion of a typed parameter with a `null` default into a nullable
type. PHP 8.4 deprecates this (E_DEPRECATED, emitted when the class is
loaded), so any consumer autoloading LoginRequest on PHP >= 8.4 gets:

    Struzik\EPPClient\Request\Session\LoginRequest::setNewPassword():
    Implicitly marking parameter $newPassword as nullable is deprecated,
    the explicit nullable type must be used instead

Use the explicit `?string` type. This is the last remaining implicit
nullable in the package (every other optional setter already uses
`?string`/`?int`), behaviour is unchanged, and `?string` is valid on
all supported versions (php ^7.4|^8.0).
Same PHP 8.4 implicit-nullable deprecation as the LoginRequest change, in
the three other spots in the package that still relied on it:

- ResponseInterface::get() / getFirst() — `\DOMNode $contextNode = null`
- UpdateContactRequest::setDisclose()   — `Disclose $disclose = null`

The ResponseInterface ones are the most impactful: the deprecation is
emitted when the interface is loaded, so any consumer that runs response
parsing inside an error-to-exception handler (e.g. the E_ALL handler in
struzik-vladislav/epp-socket-connection) has the notice promoted to a fatal
error and every EPP connection breaks on PHP 8.4+. AbstractResponse already
uses `?\DOMNode`, so the interface was also inconsistent with its own
implementation.

After this, no implicitly-nullable parameters remain in src/.
@kiuka kiuka changed the title fix: explicitly mark LoginRequest::setNewPassword param as nullable (PHP 8.4 deprecation) fix: make all implicitly-nullable parameters explicit (PHP 8.4 deprecation) Jul 30, 2026
@kiuka

kiuka commented Jul 30, 2026

Copy link
Copy Markdown
Author

Expanded this PR beyond the original one-line LoginRequest change: I found three more implicitly-nullable params (ResponseInterface::get()/getFirst(), UpdateContactRequest::setDisclose()) and fixed them in the same PR, so src/ is now clean. The ResponseInterface ones are the impactful ones — on PHP 8.4+ they break every EPP connection when responses are parsed under epp-socket-connection's E_ALL error handler (the deprecation becomes a fatal ConnectionException). Title/description updated accordingly.

@struzik-vladislav
struzik-vladislav merged commit c3be061 into struzik-vladislav:master Aug 9, 2026
12 checks passed
@struzik-vladislav

struzik-vladislav commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Hi @kiuka
Thanks for your PR! Please recheck the EPP connection issue. It must be solved.

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.

2 participants