Skip to content

Preserve existing null values when a get() default is provided - #56

Open
Zhuyuyangyy wants to merge 3 commits into
dflydev:mainfrom
Zhuyuyangyy:fix/null-valued-get
Open

Zhuyuyangyy wants to merge 3 commits into
dflydev:mainfrom
Zhuyuyangyy:fix/null-valued-get

Conversation

@Zhuyuyangyy

Copy link
Copy Markdown

Summary

Closes #55.

get() already distinguishes missing keys with array_key_exists() during traversal, but its final return replaces an existing null with the caller's default. Return the traversed value unchanged, consistent with the interface contract and the v3.0.0 null-key fix. Missing paths still use the existing default/exception handling.

Add regression coverage for top-level and nested null-valued paths, has() consistency, and an actually missing path. Clarify the interface/README and add an Unreleased changelog entry.

Validation

The new regression fails on the original source (fallback instead of null) and passes after the fix. On native PHP 8.2.35:

  • PHPUnit: 26 tests, 234 assertions, passed
  • PHPCS: passed
  • PHPStan: no errors (the older tool emits PHP 8.2 deprecation notices)
  • Psalm: no errors, with 3 existing informational MissingParamType notices
  • git diff --check: passed

These are the four local checks defined by composer test, invoked individually. Test tools were installed using a temporary local manifest retaining the project's tool constraints and omitting the unused legacy scrutinizer/ocular coverage-upload dependency; no project dependency declarations or lock files are changed, no audit/security blocking was bypassed in the final validation environment, and no coverage was uploaded. This does not claim a complete upstream CI run.

AI assistance was used for investigation, patch preparation, and local validation.

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.

get() still treats null values as missing keys despite v3.0.0 fix

1 participant