Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128988 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 669601A00BC for ; Mon, 27 Oct 2025 22:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761605996; bh=usMOxdEOJZJ6Lpq/IsMk4NHkkag4x+nmjM5xEEYORCw=; h=From:Date:Subject:To:From; b=kwYGTKx8SboUBNZgnEja+QaVyrfJDdNOuseHY+VSKb1qRYqDfhU9hqcVIt5aPS2DQ SXoc98n+v4I1tayihu6Mm00XUf+2RcVs1hkdf1dWYt5QvY6l6WOnT08vYS+3ykNPkY pPSfRBHSBsNj9jSm7TgwETdE4wCovivF0PaiyDS9GRK1QoiG8kdvRypQUdaqiVHLCe cFT+bgZGxVdSo5c8W2dD3ksSLqXUvdo3teoLak6k9msMwWQfm7CkEGMUFwofNsR5+r iIwfpDmyArHYdNeRaSkyPw4LTYOYCQHqt4Y7betwdVl3DLJrS6f4+QsMIaTtC8cAaf 5ysZ+Gs26PqEQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2CAB5180050 for ; Mon, 27 Oct 2025 22:59:56 +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.2 required=5.0 tests=BAYES_40,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,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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, 27 Oct 2025 22:59:55 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-b6cee846998so3554593a12.1 for ; Mon, 27 Oct 2025 15:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761605989; x=1762210789; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=usMOxdEOJZJ6Lpq/IsMk4NHkkag4x+nmjM5xEEYORCw=; b=mLOkjbiMWAGP0+qPKk3R2jnisfNGCMC8vb3Ro9CGmWUiYWgJdowyeJhCY61toEemWt MtxXUorDyDJbIAxuaNEr4ATKpcF24FVorPWPNj5yzOwlMKFceD+cJzcNAkUQfu3oByUO EhuliLsiW6SevjWp5w9p5LRJCeWdET199bvg0jN4PElnYt8RrMRokEWnUcSx1DVevAMD 6trPwY08m9pPzFsVNhEDU681eX1BpYJ3qfhpk/DsswmqqJoCW4858gR7mluUnc0SVM4F li/HfmcHBQbGy6XNB8STrLmiD730Z//0qnnj0btBVggZyjOhfzvVHeNH3Jpi9tC2lTna qyNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761605989; x=1762210789; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=usMOxdEOJZJ6Lpq/IsMk4NHkkag4x+nmjM5xEEYORCw=; b=hwqgHWr6JYEgK9TwN7PwnPPAEuNBqV/7+GNyrpeIhsFSM6VER/OO8FJsz1oG8zKvwU lxmUrWbd7WxaSovQH2WpwhRWwhvy4dReW3bPNGKjiOrsOecNpdwI9ANXa6qVxDE0Bt9N QbRYvjF5F2W3hMqXSIFPg1dQyPdZMcePmanUG9V2yevhmU3aX18j84u+CUxSc70o/3L3 dHiiQazmn7bGPGCL0oCXOFbqBzDNjLHsT4l+CNM72T+hdz8HCi8s6mRAgSKNRQXXZfJ3 9TnK4Pk3QheEcA8zno6mHyiNdddxx8Bit7WN5MDgErJOCxtrBuDQ76gTSt8BkuaLMfq0 1shA== X-Gm-Message-State: AOJu0YxwTaHXaDbQE/izpQm0ST5kHwopfAKWLkSVHcYXu8vShT3hEF8N uS1d09zIjMAK/TLaAVGv82bzKjSdNQIlYAx4r3cPmJQUKKnYaeJu7UuVf4t8E2WU93J67QFS3vo izNYXbLUC6euQhxQISSBiIfFG8A7yp8Vil4+0brE= X-Gm-Gg: ASbGncs2ypa/A//m0nGsBEX6aaIr5m5NePDEs4Ypt0k2z2apQfS2PIJgEft8J77q52K 6VpYVCHt5VCXqyraHrNzu0x4L96fAyDTd0yuB44MQfn+y+2IjtE3EQf3/98PiLg1QRuqRzCs7at GiiuHuQ6eK4hhyovTKwxjC/h2Sh3QnVQ6SEC535UFEAffbw+HrvyO/sXGTtbT/S5Tha3voN039D KgHUqfZu64kU0hbxw7ND/ZSnIdK3Pg7nVyusfyu6SDdM5ahWP0mlaG2NKGECd9sw2kr7E0= X-Google-Smtp-Source: AGHT+IHoX2UnYBI+W1rOOrc/qnxeTY6GAtagZNPUGFZLo7EvkQ6nTdFzDGykErd8WQT/WQULY0lboGKpMjzFycBrQYY= X-Received: by 2002:a17:903:3c6e:b0:266:3098:666 with SMTP id d9443c01a7336-294cb3ecc0cmr16547355ad.32.1761605989435; Mon, 27 Oct 2025 15:59:49 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 28 Oct 2025 00:59:38 +0200 X-Gm-Features: AWmQ_bnOuiCzVtKG-zEeaxJnElNQGBn81tDqnGiOyQI229b6eN3t1WUaVy0loWM Message-ID: Subject: [PHP-DEV] [RFC][Discussion] Add #[NoSerialize] attribute for excluding properties or classes from serialization To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: lnkvisitor.ts@gmail.com (Dmytro Kulyk) Hello internals, I=E2=80=99d like to open a discussion about a new proposal introducing the #[NoSerialize] attribute, which allows developers to explicitly exclude properties =E2=80=94 or even entire classes =E2=80=94 from native P= HP serialization. RFC: https://wiki.php.net/rfc/no_serialize_attribute Implementation: https://github.com/php/php-src/pull/20074 The primary goal of my series of proposals is to gradually reduce the responsibilities of __sleep(), which today is used both to filter which properties should be serialized, and to perform pre-serialization logic. Before proposing significant behavioral changes to __sleep(), we first need to introduce clear, attribute-based alternatives for its common use cases. This RFC represents one of these preparatory steps. It introduces an explicit, engine-level mechanism (#[NoSerialize]) to declare which properties or classes should be skipped during serialization =E2=80=94 without requiring __sleep() to handle that responsibility. Please also consider the related RFCs (to be discussed separately): - https://wiki.php.net/rfc/sleep_without_return_array - https://wiki.php.net/rfc/not_serializable_attribute Together, these proposals aim to clarify and simplify PHP=E2=80=99s object serialization model by moving away from overloaded magic methods toward more explicit, declarative mechanisms. Best regards, Dmytro Kulyk