Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121976 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57071 invoked from network); 9 Dec 2023 16:34:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Dec 2023 16:34:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8A482180040 for ; Sat, 9 Dec 2023 08:34:56 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.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,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 ; Sat, 9 Dec 2023 08:34:56 -0800 (PST) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-54dca2a3f16so5516759a12.0 for ; Sat, 09 Dec 2023 08:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702139680; x=1702744480; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ODXfAfbWhjQk6izgig+gN79QQHhWvjjFOJqvdi5oBYg=; b=JLcGFvFn7uKxAkenPI2ghYBtcMUq4hsru8Aag32xU1xCgz28OmgyQT4Jg2tBdqsXA4 lxY8uZ+htoMIoGmJf5qaTs5bai73+DWAFyauhGdznS9fURxFrUvtaUWuWkh6v2idlT2M VuW9+Obevb8G7WiMHl9A2OYtSLJLyBBvSJo5KcaXfaKUW4eoihBCEsQ3tXqqYIOQFxkr LfJGa239CVvvGeeYYIhYf1TRHZo8aUNzo378HDDw6yPWu6eybw5T19+H7YCz7lazKVLU PcAwnlvTvRHlzTgmUGIK/fk6LCzAvUl2gKSwleOAMDmx3myVSfl3Pp/6CtmNNLP+vqYN zHFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702139680; x=1702744480; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ODXfAfbWhjQk6izgig+gN79QQHhWvjjFOJqvdi5oBYg=; b=L74XYaCIYKC4PZDzerw1QL+hxUHxMNVUFWEJxAa4i/D02Wz0cYnpPKi3C807hYelXK Jc268wpoPMloexnI06hU0iG05ACW/mtg7RnjYAXkQW/hMLfhauDEKKlXakdBWo81Ke5g rRjcnCyFX6bnVrpj40qtg2jaClwurQiIJQ8adi+iNeJBwSISWa3Hh4N7cE7udyRsXe0U JLXP0ZffDpyjP3mAfM3g2qwHAY4cEcwOyx2aK2A9FzBDTVLQQe9WtKccyUKToF5BPc9E 4EM4B6BOmxOH/Q5+J9d4miyC+boO+bocJ8honwFH3MDmWoCdUudnseoCJS3HWEKs7LU0 4Dhw== X-Gm-Message-State: AOJu0YxDKg3RBCAEO4gNbKwiFV9swX0KTOIago9BMw15oQ48K5G3YLRX pYZgX1XYf3rMNOsRoDHS7HkvymQqn9U= X-Google-Smtp-Source: AGHT+IHvs57y/BmVKKt70gGaiYTKdbog3ahWBBV/tmo6WzWXEUND7axIFSSUtr/QETFL6gaTsLQbaw== X-Received: by 2002:a17:906:1d12:b0:a1c:e846:61db with SMTP id n18-20020a1709061d1200b00a1ce84661dbmr2095239ejh.49.1702139680354; Sat, 09 Dec 2023 08:34:40 -0800 (PST) Received: from [192.168.0.59] (178-117-137-225.access.telenet.be. [178.117.137.225]) by smtp.gmail.com with ESMTPSA id hw15-20020a170907a0cf00b00a1f761d9ffdsm1635180ejc.177.2023.12.09.08.34.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Dec 2023 08:34:40 -0800 (PST) Message-ID: <007ca2a5-53af-4abf-8877-7f51699bafba@gmail.com> Date: Sat, 9 Dec 2023 17:34:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: internals@lists.php.net References: <20add1b7-24ed-42be-ae84-99ef81480fa2@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Discussion] NotSerializable attribute From: dossche.niels@gmail.com (Niels Dossche) On 12/9/23 17:28, Larry Garfield wrote: > On Sat, Dec 9, 2023, at 10:17 AM, Niels Dossche wrote: >> Hi Max >> >> On 12/9/23 13:30, Max Semenik wrote: >>> Hi, I'd like to propose a new attribute, #[NotSerializable]. This >>> functionality is already available for internal classes - userspace should >>> benefit from it, too. >>> >>> The RFC: https://wiki.php.net/rfc/not_serializable >>> Proposed implementation: https://github.com/php/php-src/pull/12788 >>> >>> Please let me know what you think. >>> >> >> Thanks for this proposal, it is a sensible addition in my opinion. >> >> I do have a question/remark though. >> The example you wrote in your RFC (with MyClass implementing __sleep >> and __awake) is not equivalent to adding #[NotSerializable]. >> This is because if you create a child class of MyClass: >> >> ``` >> class MyClassChild extends MyClass >> { >> public function __sleep(): array >> { >> return ...; // real implementation instead of throwing >> } >> >> public function __wakeup(): void >> { >> ... // real implementation instead of throwing >> } >> } >> ``` >> >> Then this subclass MyClassChild will actually be serializable. >> If you instead put #[NotSerializable] on the parent class MyClass, then >> the child class won't be serializable even if you implement the >> serialization methods in the child. >> Is this intentional? If yes, this should probably be clarified in the >> text. > > Attributes do not inherit automatically, so it's the opposite. A child that is not marked #[NotSerializable] would be serializable. (Whether that's good or not is a separate question.) > I know attributes aren't inherited, but the ZEND_ACC flag that this uses _is_ inherited. Try this out yourself: ``` > --Larry Garfield >