Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128787 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 E0C541A00BC for ; Mon, 6 Oct 2025 10:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759744880; bh=SDhSGJx7w4o4fF1tnqpfrSywHgVa4/KQNatlTl8qmys=; h=References:In-Reply-To:From:Date:Subject:To:From; b=j3h3xomqahHesT/enRKGntkP5ilX9ezhWzZv6XxBAMZBwQ0xL+mEk39LgrzUiVc03 A+679bsU0y1VXfj3TF/MmsvX8usqohICMJvn9o48zq5pRJ7RGsqUqd5P90SYogDXeP w0E7vWtZpMonZSpr4X2cBm9ZOZpvQK720UyrPI5zC5j5l57h2CoJtWYQVPuFhMydxZ sX7qbA50lZfSezNqTnG0swtjlw/YE9mQ08I4zZP8puOw0432Ni2qWxUXJuKRUIKDnN ykxGB/rcx+FPDDqYJLjrK4vcVdc7+TL8Vf+zXHXkwwVx68D+2dMSxvurnkZLwcxaXU QlpIwA2KxRWJw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 910DC180055 for ; Mon, 6 Oct 2025 10:01:16 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (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 ; Mon, 6 Oct 2025 10:01:16 +0000 (UTC) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-795be3a3644so28362266d6.0 for ; Mon, 06 Oct 2025 03:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759744952; x=1760349752; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SDhSGJx7w4o4fF1tnqpfrSywHgVa4/KQNatlTl8qmys=; b=CYOqWNiT+K4JmTjD9igHgNrBpd8lvtYjEYfSVzGZqz0MGiQPEoGjnMN8BpH7JqnczL Rv/I9DW4U1xajy58ek/PnkCDUEr7dZrEkrLln5xo9TlkW8MfAO6UTp58b/zFz7Q7cbWW i3y2mtZEECq0H1tl1P9cvnJ6WmdfmwLrHSnd9S4MRAPkKZmMNoTv3vqy7//iBikyi7iK D5c8SR4E1kP7rCNxztqqCnnPplI+8Dl2MVPD0SgdYDgyq56r4Y4m+YJU8Tzu2D41/TVl b7JmNYLHq0ROPbkFKhAcxa9rO+nYg13O54t8NUl17OCb2a5ftL1NB/RUHc8n+8+TJQeU l+kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759744952; x=1760349752; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SDhSGJx7w4o4fF1tnqpfrSywHgVa4/KQNatlTl8qmys=; b=HUiapro+BSZeT6G5zcNtBXt0NcjlG5YNxs4zroFF7qh1XgoxDZMKYRCTz9JPlVeU9a GYaf07ykgnu9NazzZbB+Z7ydvjRNmlXyIdlJaBo4cgRw7058gkB3AwUB7xDTWCu7fpJQ pwskuklRo4T42i1FYiuA4lJQD9Om0DM/gXc1AEHuGj4Vfjn1lRQJtnGOtG/q7wVm0DEK mn5DorHycP7iZ0qXOkGTWJJ3Sn+wdHA1lDw9dMfK4o1tjcPUwTH6LaA6lUdLoJRxo4Nz tbXn8TLOKC640CEPVbpfGDEE7b/9ujJHp5EvY7RhCu4WAvJB0XSbtUuXV53xUdltc4Vr I9+A== X-Gm-Message-State: AOJu0YxGDDr8lGA56104gs7w5wSUxCxSDRi9WZkIZ0mEoyq0N3/SrT7N +F4ilHmS5cwv+42EYEGjeykzSKdBmjHTiJB7KF7z9pz6lS3aOQRDBbdPH75spcMUpBiLmGOfhDj iiCM/IVxXIwan60dUq1nwrfkrYdPNmXxUVexcDFI= X-Gm-Gg: ASbGnctE/A8gdIIuVcgYjFy47CXWK7Aa9uGCt7wurW2MWPVhqhWHYoq2jOjr2CLC0U7 lvqF4EuTe/JT59vMnggNrL9QgZBMuwLgt1ujx2xzI116ng0WnJJtTCiOfU0tTLLv1e56HaFF92j slheRcvMl7VYbwRS02QJJ9pxWBV8jA4DOTcpV5c8+i86+89KJ9eWj99NY49Vdz6d7gDYeTCre3K lBI2apubiOTIqOFxkxoVcaI0dWfkLFDMIq3+5dzOYBvlii8BouwV1CnEktmjMB3EA== X-Google-Smtp-Source: AGHT+IHRRQBTM03Wh6xiEXIl8HSIpLdXdugneZBYi73eERjkBAngIbMow1trnp6EqYuyPv/fZmsuvvqyAMZE8ezwDdI= X-Received: by 2002:ad4:5d45:0:b0:7ab:da21:bab1 with SMTP id 6a1803df08f44-879dc7ba0e8mr121217376d6.6.1759744952404; Mon, 06 Oct 2025 03:02:32 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 6 Oct 2025 12:02:21 +0200 X-Gm-Features: AS18NWAhSSdM5-zLZfW6acJ3qwZWjc_N6HKWs8D11biMVIEqEazTn7tG38hqiV8 Message-ID: Subject: Re: [PHP-DEV] [RFC Proposal] Add #[NoSerialize] attribute for excluding properties from serialization To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Dmytro Thanks for your proposal. This seems like a reasonable use of attributes. On Mon, Oct 6, 2025 at 12:16=E2=80=AFAM Dmytro Kulyk wrote: > > This proposal introduces a new attribute, #[NoSerialize], that can be > applied to class properties to explicitly exclude them from > serialization when using PHP=E2=80=99s built-in serialization mechanisms. A few things: * How does this interact with inheritance, i.e. is this flag inherited to overridden child properties? I would assume no, as with other attributes. But it would be good to spell it out. * There are other forms of serialization, most notably JSON and var_export(). Are these affected in any way? Does it make sense to have a universal solution? * There may also be a benefit to marking classes as entirely not serializable, which would throw when encountering the class during [un]serialization. We have some of those internally. [^1] Ilija [^1]: https://github.com/search?q=3Drepo%3Aphp%2Fphp-src%20%40not-serializa= ble&type=3Dcode