Skip to content

Treat null keys and section names as empty strings on PHP 8.5 - #8

Merged
TomK merged 1 commit into
masterfrom
null-keys-php85
Oct 22, 2026
Merged

TomK merged 1 commit into
masterfrom
null-keys-php85

Conversation

@TomK

@TomK TomK commented Oct 22, 2026

Copy link
Copy Markdown
Member

Passing null as a key or section name (getItem(null), $section[] = $v, addItem(null, …)) raises Using null as an array offset is deprecated on PHP 8.5, and a null INI path or string raises a PHP 8.1 Passing null to parameter deprecation. Projects that turn deprecations into exceptions see these as failures; this is what motivated #5.

  • null key or section name: stored and looked up under '', as before; no deprecation.
  • null INI file path or string: throws the same RuntimeException as '' did; no deprecation.

Signatures are unchanged and PHP 7.4 is still supported. The 2.x line throws on null instead.

Test plan

  • New NullKeyTest covers each case. With convertDeprecationsToExceptions on, all 7 failed on PHP 8.5 before the fix and pass after.
  • Full suite (107 tests) passes locally on PHP 7.4, 8.2 and 8.5.

🤖 Generated with Claude Code

PHP 8.5 deprecates null as an array offset, and 8.1 deprecates passing
null to string parameters. Config used caller-supplied keys, section
names, INI paths and INI strings directly, so a null from the caller
raised a deprecation, which is an exception where deprecations are
converted. Each is now read as '', which is what PHP did implicitly
before, so stored keys and thrown exceptions are unchanged.

The tests convert deprecations to exceptions so CI catches new ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TomK
TomK merged commit 240bbf8 into master Oct 22, 2026
7 checks passed
@TomK
TomK deleted the null-keys-php85 branch October 22, 2026 11:50
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.

1 participant