PHP 8.5 | CaseInsensitiveDictionary: final touches #984
+3
−7
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.
Pull Request Type
Detailed Description
PR PHP 8.5 | Fix various "Using null as an array offset" deprecation notices #956 added some defensive coding to the
offset*()methods in theCaseInsensitiveDictionaryclass, but was a little overzealous by also adding the defensive coding in theoffsetSet()method which already would throw an exception and didn't need the extra defensive coding. This has been cleaned up now.When running the tests on PHP 8.5, two more test-only deprecation notices show up, though they don't fail the tests due to the deprecation being hit in a class constant definition, i.e. when reading the class:
In both cases, the downlow of it is that PHP would already convert the
nullkey in the class constant to an empty string at definition of the array, so whether the array is declared with anullkey or a''(empty string) key doesn't make any actual difference for the tests as by the time the data would hit the test code, the key would already be converted to an empty string.With that in mind, I've taken the decision to make this empty string key explicit.
This doesn't diminish the value of the test and the guard code for the
offset*()methods receiving anull$keyis still being tested via theArrayAccessTest::testOffsetSetWithoutKey()test and theArrayAccessTest::testAccessValidEntries()with the "Null key will be converted to empty string" data set which is still in place as the data for that test is created via theDATASET_REVERSEDconstant (instead of theDATASETconstant). This was previously designed this way explicitly to allow for testing thenulloffset case.