Skip to content

Conversation

IonBazan
Copy link
Contributor

@IonBazan IonBazan commented Oct 8, 2025

Following up #57137 and #57231 - fixing remaining null array index accessors.

Remaining deprecations include:

Comment on lines +149 to +150
return is_array($channels[$connection ?? ''] ?? null)
? $channels[$connection ?? '']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@taylorotwell taylorotwell merged commit 5718d44 into laravel:12.x Oct 8, 2025
64 checks passed
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.

3 participants