Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:131064 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 784CB1A00BC for ; Fri, 29 May 2026 16:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1780073908; bh=FJjiAWopwdtKfakg4LhY5Gawjd7RjCZo1nEOf0ULxpQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=E9XNkKSts9xuQ1AuyuGYDtu7cOZF33OKhMSl7RLV04VePoeGb6X0L7PYqW6mlLx2G h/MHFfwzaQAoWA1Z1AcpYmEXPIQB+ys2kT4YxnUhPtXEMFB1FTngp8f7PTUGnKERfI WYXMrXwIyLfog8akPGGgo2L0XJFgpqxgfM7LTjTavOM238Mr31pDb7aBxY8Sngr6f4 Y9tmXpFJd1bYk1aiGNMtE+IlKFVkSUhhRP8QO2paeom+y2qjIp0pgfqEWnDngCeoK/ 80OClOllUE3QLTpzxqqayV5Rz5GACS9IEuNrYMmqPzEUOQ6q7Iz8bLRicjp9aHTTFb sOEf2QTuWexSQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 493411801E0 for ; Fri, 29 May 2026 16:58:27 +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=1.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FORGED_GMAIL_RCVD, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (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 16:58:26 +0000 (UTC) Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-8cce8873b56so7749176d6.1 for ; Fri, 29 May 2026 09:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780073901; cv=none; d=google.com; s=arc-20240605; b=LzRpStQSprhLFfRxjIQSZQFrN5TjbtBNd1Y9luyZ+E3Fj8VO3p2oe0sKkjlWvvJxwt 2y9hsp1KgmuRr/H7E7Ww9u2ZVN8reALHC7dMSjSvW3KLsD7cKhOVnI2bQcEHRiY+4lZW DRL3ihSrkMk3A9OGgOnq/KzGHsFPIJMKXl7ZJgCvx7AFVp8UBvOIPe0G+4KyTqwowElz wgW5uXniZL6NhNOZ5hFl2whjEiqvveOguibC0LAzSFJltushu3jN3LGEuJC8IhW2ezYu MW0IX7jCogh8PxPMkJk3mHuf+xeoXCKcqGlo+51lMx8ycbKuRKvWUpEPosbrD6/8HHO1 66Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3C++DoTr5U7dnydp2NMwYGOjzQUMedF0V/mqv0gQCp0=; fh=Ofn+XpSLefQyxrNYeqFK5V6BgIEzMTvoqvpJ6/SQfuk=; b=YmTwqzONLfSK39hfXh116JLwwDe7pa0BXmwinqdchSvOGtEO+QnVAydpQLYIthDLAe fjCkvLWz2ILGKLkvElLvDRRtL6HiQ4/lz5JiBsF4weUmrbVNo+5Uu2j2/YS6Eeh8MNBm /V8H8Q8APJesSJ7KeQrH9qXVjVGUj//0sQ8QGw/rHK7yO6AWV78K7g/kcjtUro3EL5Gn 8AdRn15fYJP3xjZ1AnODd2Pz6+Z8oAhMy4EEzcjVZOD0BeeqFh5VBvYkoiMN2yOKQ1d7 kWfXiyLhAWpeaRplgQRnqGXIv+JvCZwpwAbuHayfMPjHCp+BAvTnkPDDLQ6zOWjR+lUx YJ6A==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780073901; x=1780678701; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3C++DoTr5U7dnydp2NMwYGOjzQUMedF0V/mqv0gQCp0=; b=g1+6psnxNd8bbIbKFdOvf+PDQSYVDfe7uOqmqqJbnlTggTP77HqrtP5KxLQCoHErWL COjbJkFNbNhdBemNMC+MzxIGSeEfU2nx3tSuwfk4JzJ1yvk5KJaV0JD+iQUXUOCo4wBK oXtjgI1YrNs6U46j7Iwub9bgUzGtsB/xfyxEaTnzkuToYb8DReAqQ5p0PuPtE5d57rD4 nnBL9rp/8Apu302ZkXjFacpxCPCiWVtbxkrWCcE3WjJZ4faC4NC16bljeH4hVT7vLNfy 4KU0xHorTeqZtxBC6ddaY+yzu3nv7WuIov7cLYBw5d//G/Lg68QZpMJ+Pe2rkLwUyjh0 MJIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780073901; x=1780678701; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3C++DoTr5U7dnydp2NMwYGOjzQUMedF0V/mqv0gQCp0=; b=h/QCV3DtNZUOkacs6oGmRdZON7MOVES2urSfFvmJofxRooeKmLXlhGvcpZ6W52dMsB izovFMeNbtsEtIwnlHUG/PQ6JzzCHQLZqBKF5iYiML+MKT54qmt4yrpRKYDtU8kNalkX gwdY74UYwzGr3+8Q0TM9BvFM9pxEdEgbdpKKrfMp+MKLGd2oTOnpTaz0idpYHdhUhh4D ZD8EzSkMmlwFftaNWIyzcaw6mRsOxs+kFDMS2EQzD2mRLMQGf/trgGMOrUkC1We+lt3H Y7cSuvApK5jF5kko5CUNYA8fCSfvMljhNzyQjpHVO+DUvoAdG99WQMzk0vCwMU0BeF8S mpQw== X-Gm-Message-State: AOJu0Yy78B/QYILJF7Lw7UKSQM1X1iX/CGmT2JR53GlhGeytdfNyAiPF UJJXSiV3CYCX/qELdE/p0YWF+Nb7oCdsK17oK75oB9EF5DMnCLzlMtnC8E6yqOJCCPNd9cqYpec shrXSp9orTbPoxxO0fdrTzfDHTmKdSumOIeiHXJA= X-Gm-Gg: Acq92OGMrpc9KB8rcdoVlh5uAkk+IbWoZiBhUxKawBqJYlTE1RVXCPOnIv9eqeYBO9l J2savutzLbh+TLBl3/G9nyXuMwDNNsRvX66M5T0fVWz9RvktWuoxY5Yc+1ygM5z3Tad+YH7ZpQU 6lVcTKETdu2CwxRa8icjNYgEQTwy7wktPhiLeTLuA2kZ70yDNyf+kUyKG+O2+jyi87PvOQ7oYg9 OQWE+1Fs/TcVOlPDaiTOlnAQzjXSExMQoQOTmpGDMWFh/8dO/oQwyauDg84UA0jRbm+tex66TIn 1Tt3P81Nt7+j7sFiJKXg8eZngaPxLBVoUx94Hf93NT3L02gr X-Received: by 2002:ad4:5ecc:0:b0:8cc:d69b:42d2 with SMTP id 6a1803df08f44-8cce476fa7amr52554516d6.0.1780073900998; Fri, 29 May 2026 09:58:20 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 29 May 2026 19:58:09 +0300 X-Gm-Features: AVHnY4LGWuBDft9LpH4_5FPOeX60-XzXbcnvko308khfmYp63vdGtDmPjdXoa6w Message-ID: Subject: Re: [PHP-DEV] [Pre-RFC] Null coalescing associative array elements To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: amego2006@gmail.com (Alexander Egorov) Thanks for the feedback! =D0=BF=D1=82, 29 =D0=BC=D0=B0=D1=8F 2026 =D0=B3., 19:06 Larry Garfield : > My first thought is that the current code, which assigns potentially null= values, works fine if you throw an array_filter() at it at the end. > > $array =3D [ > 'field1' =3D> $param1, > 'field2' =3D> $param2, > 'field3' =3D> $param3_which_is_null, > ]; > > $a =3D array_filter($array); > // $a now omits the null fields 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. > My second thought is that this is yet another reason why using associativ= e arrays as if they were a data structure is wrong and should be avoided; j= ust use a class and everything will be fine. If you need to serialize it l= ater, there's many serializers on the market if JsonSerialize isn't suffici= ent. 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 wil= l 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.