Skip to content

Commit 6b82a86

Browse files
committed
PHP 8.5 | Tokenizer/PHP: temporarily silence "Using null as an array offset" deprecation
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.... https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/f1c9394f1724ed45ca42029da330ff5c702af2a9/src/Tokenizers/PHP.php#L2254-L2258 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
1 parent acf2a54 commit 6b82a86

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Tokenizers/PHP.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,7 @@ protected function tokenize($string)
22682268
}
22692269

22702270
if ($prevNonEmpty === null
2271-
&& isset(Tokens::$emptyTokens[$tokenType]) === false
2271+
&& @isset(Tokens::$emptyTokens[$tokenType]) === false
22722272
) {
22732273
// Found the previous non-empty token.
22742274
if ($tokenType === ':' || $tokenType === ',' || $tokenType === T_ATTRIBUTE_END) {
@@ -2287,8 +2287,8 @@ protected function tokenize($string)
22872287

22882288
if ($tokenType === T_FUNCTION
22892289
|| $tokenType === T_FN
2290-
|| isset(Tokens::$methodPrefixes[$tokenType]) === true
2291-
|| isset(Tokens::$scopeModifiers[$tokenType]) === true
2290+
|| @isset(Tokens::$methodPrefixes[$tokenType]) === true
2291+
|| @isset(Tokens::$scopeModifiers[$tokenType]) === true
22922292
|| $tokenType === T_VAR
22932293
|| $tokenType === T_READONLY
22942294
) {
@@ -2311,7 +2311,7 @@ protected function tokenize($string)
23112311
break;
23122312
}
23132313

2314-
if (isset(Tokens::$emptyTokens[$tokenType]) === false) {
2314+
if (@isset(Tokens::$emptyTokens[$tokenType]) === false) {
23152315
$lastSeenNonEmpty = $tokenType;
23162316
}
23172317
}//end for

0 commit comments

Comments
 (0)