Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122097 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14921 invoked from network); 3 Jan 2024 14:19:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2024 14:19:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1704291602; bh=YWFidyHMX8HgzCUF670b01VPsNQRVkL0H1+U0pm6x1g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kn52pnCJgwWhku9U6+xdq/obei0Hg0alSg0SrgjrNDq69nwS3HZRP9MAEZwTJhVMo /jtLo8lQ/BAGwEF8EZUCv+URE195MUn9CG+piKRrRBNe1wIHx08ezTktLddL6nS+Ri zLMVBG5JOOY8k59gH9E+OBJPK86RGhZmF6bhFQbLZmOqK7hefA2icK+UA9Vm+MMbnm KbASq5TJHhhGrzDPQey4Iuf/SQG1cP3ZCLKVFd71L+bjAVo7R3moyqPrIDGylf6D7C A1xMExsVlM1EQt+8U51/099TZ3UB4n8ItQ2tXCa/o3lwga1ALFRslCYfxa/wSP2QDg ionC5OVDUijug== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9934B18004A for ; Wed, 3 Jan 2024 06:20:01 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLY,HTML_MESSAGE,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-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) (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 ; Wed, 3 Jan 2024 06:20:01 -0800 (PST) Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-dbd71f33cd3so7938718276.3 for ; Wed, 03 Jan 2024 06:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704291570; x=1704896370; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1JsKeXWCEXIOHmFJdZyOYtem7ehZ/cifEr5jtmkzt5E=; b=EvIf2wsUkyPmeAc2T5FcOjiZSbiuldT6OgxZLAsw+sNLTER+pvhorEb8Sa1UEY8h6n DX3CdVpFKffE5yS7kmps9fx6dCcgkoEjcOTXxn72Xwd+5vdZ5dDWca3/XkrA2aHiUP2t PCPmlL5Ft92Zn5SNlZz3QWZb3qtQ/Dh95cxR4UP7l1tg2v9CCqTX/A8wonL1cJWIEh9K rRSEZW62TJ6uiugVlbBBLahbmdn8nx6ku1XGE7EDf5mHTVCfbJRmmlADvGJtrnQEQvJw D4MLdb/tA+9eH05jByJcmoZPpMu6H9LHcDunKl+OFhTlJuVdVME4ZOq58sB2gF9dNJ0A 2k7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704291570; x=1704896370; h=cc: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=1JsKeXWCEXIOHmFJdZyOYtem7ehZ/cifEr5jtmkzt5E=; b=iVVDKt5ydtOn6x37f21kNVglIeAe+NP84NbXmL0cgX/OP/zcq7Cu085jPZg2jzn6HQ Ium66xqnstnbeGpK/naNj8K0loSrq/w3yVOMQZ2zINJ5lNnPA4/w4WVyuaruNzgDt4hx YtRh8C/mtSDW7lhSkPm1XNvwDqssGM4nYjpgPDpedAQCxUEHF694WIJ7I+ftB0R6nsQ2 hQsctfasjkNi7tga+j2UJbonUq60acNHuHBU93WWC4ET9+DYg+xk2+A5HjZ1v9YMSy4I NE+PKt8TmdVjmjuKuQkRfw1jUHoSuo3wUY7U7HNLu9/0WEn1HxOR0NXrl1ZhndUQmTuF 3ByA== X-Gm-Message-State: AOJu0YyNKxbNNQA4g2tVHa8lF41AI+FqzKsrFg6AprFtCDQhQClOUq6d HsPabxfCF1WM1fTyXQ+hpFKOsZhZIbn3l1GthaE= X-Google-Smtp-Source: AGHT+IGM2nzQm8i3h1hswAZII03tYA7xOA+8suqebbR8/buDSu8yRn+BSnrsV2EjttzuksGuRzfR1NCaExD13iw1eoQ= X-Received: by 2002:a05:6902:1b06:b0:dbd:4fb7:f446 with SMTP id eh6-20020a0569021b0600b00dbd4fb7f446mr10513158ybb.103.1704291569655; Wed, 03 Jan 2024 06:19:29 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 3 Jan 2024 15:19:18 +0100 Message-ID: To: Nicolas Grekas Cc: Max Semenik , Internals Content-Type: multipart/alternative; boundary="0000000000009a63de060e0b4d7c" Subject: Re: [PHP-DEV] [RFC][Discussion] NotSerializable attribute From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --0000000000009a63de060e0b4d7c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =C5=9Br., 3 sty 2024 o 11:10 Nicolas Grekas napisa=C5=82(a): > >>>> =C5=9Br., 3 sty 2024 o 08:12 Nicolas Grekas >>>> napisa=C5=82(a): >>>> >>>>> Hi Max, >>>>> >>>>> 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. >>>>> > >>>>> >>>>> Regarding the inheritance-related behavior ("The non-serializable fla= g >>>>> is >>>>> inherited by descendants"), this is very unlike any other attributes, >>>>> and >>>>> this actively prevents writing a child class that'd make a parent >>>>> serializable if it wants to. >>>>> >>>>> To me, if this is really the behavior we want, then the attribute >>>>> should be >>>>> replaced by a maker interface. >>>>> Then, a simple "instanceof NotSerializable" would be enough instead o= f >>>>> adding yet another method to ReflectionClass. >>>>> >>>> >>>> This should be possible without ReflectionClass, see >>>> https://3v4l.org/N3fmO >>>> >>> >>> Sure. >>> >>> My main point is : why use an attribute? this should be an interface to >>> me. All semantics match an interface. >>> >>> >>>> From the serialization libraries you can find similar attributes >>>> >>> >>> Those a very different, because they tackle the problem from the >>> *external* angle: the attributes there describe how a system *external*= to >>> the class itself should best serialize an object. There, attributes mak= e >>> sense, because they enrich the description of the class without forcibl= y >>> telling what to do with the object >>> >>> But in the RFC, we're talking about the object deciding itself how it >>> should be (not) serialized. This is enforced and thus belongs to the >>> typesystem - not to an attribute. >>> >> >> But then what should implement the NotSerializable interface? >> If you want to ignore a string-typed property there would be no option t= o >> mark it with a NotSerializable interface >> Consider "baz" property in this example: >> >> class Foo { >> protected int $bar =3D 1; >> #[NotSerializable] >> protected string $baz =3D 2; >> } >> > > > The attribute is #[Attribute(Attribute::TARGET_CLASS] so I'm not sure why > you consider this as it's not mentioned in the RFC (and I'm not sure it > would make sense). > Apologies, apparently I didn't read. Cheers --0000000000009a63de060e0b4d7c--