It's not mentioned in the documentation, but when calling http_build_query on an object, public null fields are ignored.
<?php
class A {
public int $publicNotNull;
public ?int $publicNull;
private string $privateNotNull;
public function __construct()
{
$this->publicNotNull = 2;
$this->privateNotNull = "Test";
}
}
$a = new A();
echo http_build_query($a); // publicNotNull=2
?>