Bug
Data::get() returns the default value when a key exists but has a null value, contradicting both the interface documentation and the v3.0.0 changelog which states this was fixed.
Version: 3.0.3
Code
Data.php line 138:
return $currentValue === null ? $default : $currentValue;
The traversal loop (lines 126–136) correctly uses array_key_exists() to distinguish missing keys from null values. But line 138 throws that distinction away by treating null as "not found."
Reproduction
$data = new Data(['setting' => null]);
$data->has('setting'); // true ✓ — key exists
$data->get('setting', 'fallback'); // 'fallback' ✗ — should return null
$data->get('setting'); // null — correct by accident ($default is null)
Inconsistencies
-
Interface contract (DataInterface.php line 65): "If the key does not exist, an optional default value can be returned instead." — specifies missing keys, not null values.
-
CHANGELOG.md v3.0.0: "Fixed get() method behaving as if keys with null values didn't exist" — this exact bug was claimed to be fixed.
-
has() vs get(): has('key') correctly returns true for null-valued keys (uses array_key_exists), but get('key', 'default') returns 'default' as if the key doesn't exist.
-
ArrayAccess: isset($data['key']) returns true (via has()), but the underlying get() would return the default instead of null.
Suggested fix
Simply return $currentValue as-is. The missing-key case is already handled by the loop above (lines 127–133), which either returns $default or throws MissingPathException.
Bug
Data::get()returns the default value when a key exists but has anullvalue, contradicting both the interface documentation and the v3.0.0 changelog which states this was fixed.Version: 3.0.3
Code
Data.phpline 138:The traversal loop (lines 126–136) correctly uses
array_key_exists()to distinguish missing keys from null values. But line 138 throws that distinction away by treating null as "not found."Reproduction
Inconsistencies
Interface contract (
DataInterface.phpline 65): "If the key does not exist, an optional default value can be returned instead." — specifies missing keys, not null values.CHANGELOG.md v3.0.0: "Fixed
get()method behaving as if keys withnullvalues didn't exist" — this exact bug was claimed to be fixed.has()vsget():has('key')correctly returnstruefor null-valued keys (usesarray_key_exists), butget('key', 'default')returns'default'as if the key doesn't exist.ArrayAccess:
isset($data['key'])returnstrue(viahas()), but the underlyingget()would return the default instead ofnull.Suggested fix
Simply return
$currentValueas-is. The missing-key case is already handled by the loop above (lines 127–133), which either returns$defaultor throwsMissingPathException.