Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 18, 2024

. Passing null or false to dba_key_split() is deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_null_and_false_to_dba_key_split

This commit introduces a new sniff to detect and flag this.

The sniff checks for calls to the typical dba_firstkey() and dba_nextkey() functions being passed straight into a call to dba_key_split(). Both dba_firstkey() and dba_nextkey() can return false, so their return value needs to be checked before passing it on to dba_key_split().

As a fall-back, though much less likely to match real-world code, the sniff also checks for hard-coded false or null values being passed to a call to dba_key_split().

When the key is passed as a variable, the sniff will stay silent (undetermined).

Includes tests.
Includes documentation.

Refs:

Related to #1731

…llFalse sniff (RFC)

> . Passing null or false to dba_key_split() is deprecated.
>   RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_null_and_false_to_dba_key_split

This commit introduces a new sniff to detect and flag this.

The sniff checks for calls to the typical `dba_firstkey()` and `dba_nextkey()` functions being passed straight into a call to `dba_key_split()`. Both `dba_firstkey()` and `dba_nextkey()` can return `false`, so their return value needs to be checked before passing it on to `dba_key_split()`.

As a fall-back, though much less likely to match real-world code, the sniff also checks for hard-coded `false` or `null` values being passed to a call to `dba_key_split()`.

When the key is passed as a variable, the sniff will stay silent (undetermined).

Includes tests.
Includes documentation.

Refs:
* https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_null_and_false_to_dba_key_split
* https://github.com/php/php-src/blob/634708a14f9546cc81bc5f9bf269ec0c46743a0f/UPGRADING#L423-L425
* php/php-src 15297
* php/php-src@bb2836e

Related to 1731
@wimg wimg merged commit 004aed3 into develop Sep 7, 2024
@wimg wimg deleted the php-8.4/new-removeddbakeysplitnullfalse-sniff branch September 7, 2024 19:52
@jrfnl jrfnl added the PHP: 8.4 label Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants