Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:131065 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id A635B1A00BC for ; Fri, 29 May 2026 17:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1780074822; bh=+fZu0DBG7gkMVT9aZ6NnoXYTOeQ1Qwo6FHPujriVdsI=; h=Date:From:To:In-Reply-To:References:Subject:From; b=k6cuPch50+hKfRyYSxMGey6LJXS896n6AeDNI5gEWvHX+fAExLvppeU+w6qxvX2TU 9XQ+6Q33G2zwCAluIUnFIBAcJ+425t5OyxDmt2iGsIJvvFAUqc40UJNRMpTpsb81SA ueTVCLTNLDcAcKJ1eEUdgc16XEoyQs1WkYsmwUbMDKQm0oSCJyYPaRZs+oE8A/887/ PRwbGZ+iuAjWiRp21QSG4q/eg4YgEJA6pAwbCz5SKJ8JOaWsxwMFuw3e3T3/GkA5e9 3kGmwCT/v75R/ENhaVeqkeGXKYNGvvqCsjdyrd2B0WRRWsZ/uhXm3dT6tZIEw026C5 hPsQnvgRnvzAA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3A6E11801D8 for ; Fri, 29 May 2026 17:13:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b8-smtp.messagingengine.com (fout-b8-smtp.messagingengine.com [202.12.124.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 29 May 2026 17:13:40 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 912EE1D000B9 for ; Fri, 29 May 2026 13:13:35 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Fri, 29 May 2026 13:13:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1780074815; x=1780161215; bh=2zDEZvBpkYeeY1Ih7YZuB CBAurjWG1dLaWSzXnGwRS0=; b=jWzdqONjkwAjR08JyhKs+8Lticn3iFWTZ6/rK si7/qcoYzVbqpYNDoCSnFblV3fqvOTAc8RDZpYR5aGslRDX/sdYq6RvYaycCcCEf bWDBPPiNCEx6j7CzjTFG7dgOHlclQ1y9gnOU4qYt891z2eauh1LQ1twjE+vWSmaC KETKQ1POKpfWsTNfnw2D/zv0Q2gzKMvh8KsLDWUheKrntqCwFfIPuw0srQhV6GeB JKuFdBycMgKCK8tpH5sEcankYfOHyuig8vtc4zqBbjp9A3YQFF9pWM/zKvVpBvAK 2BygGyjzst3vBlubfEROzn5KhuxlpQDLOZF8tp2+Fh5CX69jw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1780074815; x=1780161215; bh=2 zDEZvBpkYeeY1Ih7YZuBCBAurjWG1dLaWSzXnGwRS0=; b=wDuPDY1gcvNminX8l llKTb298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.phl.internal (Postfix, from userid 501) id F10C8700065; Fri, 29 May 2026 13:13:34 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: AOnToJ90c1og Date: Fri, 29 May 2026 12:13:14 -0500 To: "php internals" Message-ID: <1c8f3c94-42fe-439f-80b2-6c2273b22f55@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [Pre-RFC] Null coalescing associative array elements Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Fri, May 29, 2026, at 11:58 AM, Alexander Egorov wrote: > array_filter will only cover the cases when you need to filter all > fields by the same criteria (null's in this case). > But it does not fit the case when you still have some mandatory fields > even if they are null, but some are optional. > At least in the simplest form, but otherwise in more complex forms > we'll still come up with additional code. A data format that has a mix of required-even-if-null and optional fields is a broken data format. We should not design language features around a broken data format. (I realize that the broken data format is often provided by a 3rd party, not the PHP developer, so it's not the PHP developer's fault that the data format is broken. But the point stands that we should not build around that.) >> My second thought is that this is yet another reason why using associative arrays as if they were a data structure is wrong and should be avoided; just use a class and everything will be fine. If you need to serialize it later, there's many serializers on the market if JsonSerialize isn't sufficient. > > Wrong or not, using arrays as an intermediate for serializing is still > very common. > Also, it is a common case when developers have their in-house > serialization mechanisms. > > But whatever serialization you use, the serialization library by itself will > still need to perform corresponding "if"'s or other logic to > conditionally include/exclude the fields. > So, such feature can prove useful for serialization libraries themselves. > > Another thing is that we don't only work with production-ready code > which presumably already > has or should have a proper "infrastructure" for serialization. We can > still work with some draft > or MVP projects where we need to do things fast and simple first. And > such feature can prove handy. Disclosure: I am the author of Crell/Serde, one of the aforementioned serialization libraries. It's also super easy to just "drop into" a project and start using, even without wiring it into a container or anything. And I wouldn't make use of this feature, as it doesn't fit the way Serde works to begin with. --Larry Garfield