The missing key vs null distinction is a real gotcha in PHP. With a decoded array, isset($data['meta']) returns false when the value is null, so it treats a present null key like a missing one. array_key_exists('meta', $data) tells them apart. Also worth noting that mixed already includes null, so if a field is only ever a value or null, a nullable type such as ?array (or array|null in PHP 8) is usually a tighter choice than mixed.
Thanks Shahabaz — that distinction matters a lot in PHP.
isset() collapsing a present null into “missing” is exactly why array_key_exists() is the safer check on decoded arrays. And agreed on the draft: KeptTools types an explicit JSON null as mixed, which already includes null. For a field that is only a value or null, tightening that to something like ?array / array|null before shipping is usually the better move. The converter output is a starting draft, not the final type contract.
Shahabaz Alam
The missing key vs null distinction is a real gotcha in PHP. With a decoded array, isset($data['meta']) returns false when the value is null, so it treats a present null key like a missing one. array_key_exists('meta', $data) tells them apart. Also worth noting that mixed already includes null, so if a field is only ever a value or null, a nullable type such as ?array (or array|null in PHP 8) is usually a tighter choice than mixed.