Skip to content

Tokenizer/PHP: investigate root cause of a particular PHP 8.5 deprecation notice #1216

@jrfnl

Description

@jrfnl

Commit 6b82a86 in PR #1215 temporarily silences a PHP 8.5 "Using null as an array offset" deprecation in the Tokenizer layer dealing with the ? character.

As per the commit message:

When running the NullsafeObjectOperatorTest, the "Using null as an array offset" deprecation gets triggered in the tokenizer layer handling re-tokenization to T_NULLABLE and/or T_INLINE_THEN.

This should only be possible if the below code at the top of the loop would result in $tokenType being null, which shouldn't be possible....

if (is_array($tokens[$i]) === true) {
$tokenType = $tokens[$i][0];
} else {
$tokenType = $tokens[$i];
}

With this conundrum in mind, I'm electing to (temporarily) silence the deprecation notice for now until there is more time to investigate in more depth.

Ref: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists

This issue is a reminder to investigate the above before PHP 9.0 comes round and to determine a permanent solution.

As that part of the Tokenizer is not sufficiently covered by dedicated tests, more tests will need to be put in place as well to validate and safeguard the permanent solution.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions