Skip to content

replace broad empty() with more explicit filters #58

@shampine

Description

@shampine

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions