---
title: "Comment by Shahabaz Alam on \"null becomes mixed on the PHP DTO\" | Hashnode"
description: "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 pre"
url: "https://hashnode.com/posts/null-becomes-mixed-on-the-php-dto/6afbb30b6c053d6c8fa19f52/comment/6afbd11c5b421c2b428b6db5"
---

[Discussion](https://hashnode.com/posts/null-becomes-mixed-on-the-php-dto/6afbb30b6c053d6c8fa19f52)

Comment [null becomes mixed on the PHP DTO](https://hashnode.com/posts/null-becomes-mixed-on-the-php-dto/6afbb30b6c053d6c8fa19f52)

[Shahabaz Alam](https://hashnode.com/@azqora)

[1d ago](https://hashnode.com/posts/null-becomes-mixed-on-the-php-dto/6afbb30b6c053d6c8fa19f52/comment/6afbd11c5b421c2b428b6db5)

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.

[Ameen Usman](https://hashnode.com/@ameenusman)

[7h ago](https://hashnode.com/posts/null-becomes-mixed-on-the-php-dto/6afbb30b6c053d6c8fa19f52/comment/6afbd11c5b421c2b428b6db5#reply-6afd232348d2e85b9f2396a1)

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.
