Repository navigation
php 8.5: fix deprecation of null as array key - #227
Merged
Merged
Conversation
falkenhawk
marked this pull request as draft
April 3, 2026 14:22
falkenhawk
force-pushed
the
php85-null-array-offset
branch
3 times, most recently
from
April 3, 2026 19:16
cb7ff09 to
5815fe8
Compare
falkenhawk
force-pushed
the
php85-null-array-offset
branch
from
April 3, 2026 19:19
5815fe8 to
5f51b6d
Compare
This was referenced Apr 7, 2026
Merged
falkenhawk
marked this pull request as ready for review
April 7, 2026 16:34
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.
Note
Using
nullas an array key (e.g.$array[$nullValue]) was a widely common pattern in older PHP codebases, so this initially looked like a possible breaking change for downstream projects.However, PHP has always silently cast
nullto""(empty string) in this context -$array[null]and$array[""]are fully equivalent - so replacing one with the other is a no-op behavior change. If your project has the same pattern, the fix is straightforward:$var ?? ''wherever a nullable variable is used as array offset.PHP 8.5 deprecates using
nullas an array offset and as the key parameter forarray_key_exists(). This was a widely used pattern in ZF1 wherenullgets passed as array key through various code paths.approach
Since
$array[null]was always equivalent to$array[''], the fix is to make the implicit cast explicit using null coalescing ($var ?? '') at the point where the variable is used as array offset. This preserves backward compatibility exactly.changes by package
Form.php$arrayPath ?? ''in_dissolveArrayValue()and_attachToArray()Db/Select.php$correlationName ?? ''inarray_key_exists()call incolumns()Rest/Server.php$this->_method ?? ''infault()TimeSync.php$alias ?? ''in_addServer()Http/Client.php$name ?? ''in_setParameter()Navigation/Container.php$hash ?? ''incurrent()andgetChildren()Translate/Adapter/Tmx.php$this->_tuv ?? ''and$this->_tu ?? ''in_endElement()File/Transfer/Adapter/Http.php$files ?? ''for array key inisValid()Filter/Input.phparray_shift($keys) ?? ''in NotEmpty validator checkTest/PHPUnit/Db/DataSet/DbTableDataSet.php$table->info('name') ?? ''inaddTable()followup to #225