if (in_array($snakeCasePropertyName, $this->excludeWhenEmpty) && empty($propertyValue)) continue;
empty() treats 0, "0", false, and [] as empty. So if someone wants to return "count" => 0 or "enabled" => false, it could disappear depending on config. That’s not a bug, but it’s a “why did my API lie to me?” moment.
A nicer library-level option is: replace broad empty() with more explicit filters (null only, empty string only, empty array only), or clearly document “excludeWhenEmpty uses PHP empty semantics.”
if (in_array($snakeCasePropertyName, $this->excludeWhenEmpty) && empty($propertyValue)) continue;empty() treats 0, "0", false, and [] as empty. So if someone wants to return "count" => 0 or "enabled" => false, it could disappear depending on config. That’s not a bug, but it’s a “why did my API lie to me?” moment.
A nicer library-level option is: replace broad empty() with more explicit filters (null only, empty string only, empty array only), or clearly document “excludeWhenEmpty uses PHP empty semantics.”