---
title: "Discussion on \"null becomes mixed on the PHP DTO\" | Hashnode"
description: "Discussion on \"null becomes mixed on the PHP DTO\". Laravel writes null. TypeScript types null. The PHP draft uses mixed. CSV prints headers with an empty row."
url: "https://hashnode.com/posts/null-becomes-mixed-on-the-php-dto/6afbb30b6c053d6c8fa19f52"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [null becomes mixed on the PHP DTO](https://kepttools.hashnode.dev/null-becomes-mixed-on-the-php-dto?utm_source=hashnode&utm_medium=feed)

Laravel writes null. TypeScript types null. The PHP draft uses mixed. CSV prints headers with an empty row.

1d ago · 1 min read · kepttools.hashnode.dev  
Read the article

-   [#json](https://hashnode.com/tag/json)
-   [#php](https://hashnode.com/tag/php)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#laravel](https://hashnode.com/tag/laravel)
-   [#kepttools](https://hashnode.com/tag/kepttools)

## Written by

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

@ameenusman

  
[View profile](https://hashnode.com/@ameenusman)

Free browser developer tools. Nothing you paste is uploaded.

## Responses 2

Markdown supported · ⌘↵ to post

[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.
