[12.x] Fix remaining PHP 8.5 null index array deprecations#57308
Merged
Conversation
shaedrich
reviewed
Oct 8, 2025
Comment on lines
+149
to
+150
| return is_array($channels[$connection ?? ''] ?? null) | ||
| ? $channels[$connection ?? ''] |
Contributor
There was a problem hiding this comment.
Isn't the problem something else here?
Suggested change
| return is_array($channels[$connection ?? ''] ?? null) | |
| ? $channels[$connection ?? ''] | |
| return (array_key_exists($connection, $channels) && is_array($connectionChannels = $channels[$connection])) | |
| ? $connectionChannels |
Contributor
Author
There was a problem hiding this comment.
No, we can't pass null to any function that takes array index:
<?php
$arr =[];
var_dump(array_key_exists(null, $arr));
// Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /in/KYhLO on line 4
// bool(false)We'd have to use null-safe operator here too
Contributor
There was a problem hiding this comment.
Yeah, that wasn't my point. I added a suggestion for the original code. A suggestion with your changes incorporated would look like this:
Suggested change
| return is_array($channels[$connection ?? ''] ?? null) | |
| ? $channels[$connection ?? ''] | |
| return ($connection !== null && array_key_exists($connection, $channels) && is_array($connectionChannels = $channels[$connection])) | |
| ? $connectionChannels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following up #57137 and #57231 - fixing remaining
nullarray index accessors.Remaining deprecations include:
PDO::MYSQL_*constants inorchestra/testbench-core- tracked in Fix use of deprecated driver specific PDO constants #57141SplObjectStorage::contains()inopis/json-schema- fixing in PHP 8.5 compatibility opis/json-schema#156league/uri- fixed in Fix PHP 8.5 deprecations thephpleague/uri-src#157, unreleased