Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122092 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99424 invoked from network); 3 Jan 2024 10:05:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2024 10:05:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1704276361; bh=IU+MJH5s9EoQegACRh+c7A788t4gmRuGilXn9fG7jKU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OM8/OdvcIQhXNRME6gRnV5r6ds9FdnuVpjW8q/Z59HPVsbOsp3mJ/Ilm1lCpfx9pF ES6TdOe4rokc66jSSXftDyVhsMiVx8Bw+hGtAg78/2QBeo8mPS/yiyE97SGkXY8LRW XLTz9VKQZkyr+e+c3e1S0Q6nMCLLnpaD4/uOdwaCJRjx2D9goGMxSDPDWrlIjc0mVb k7gwYWqj/yB5+V5iYJZdNDb6nWeXfw8HL7WGMdmy81MNATpXoxiMaxahEifqAwW341 BuTjWl8HU9b36gm2thwxZd7OSB47E+iTQknQ7ASTv/0+IQluf8sCxwgnhPyD6lxN76 HzrDxM5xMMBcQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7A2F518004D for ; Wed, 3 Jan 2024 02:06:00 -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-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (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 02:05:59 -0800 (PST) Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-dbd99c08cd6so6521759276.0 for ; Wed, 03 Jan 2024 02:05:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704276328; x=1704881128; 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=ixHL0u6VBKjtJsv7nsOUJGax3/cXO6U5lzuxjpBvrGk=; b=jG5B+xJQeKWdJR/aNKa0CZ/o66MPW5FE0WI8drWsQyqRqIFR0pAZn+P1zV1bEhMbTO zaYOV0yxIVmuOs3Hjh5BI5pDJoqlw7l7WUar4sYcqS+2lGEmf7NCiIVeno/49aY8ksPv SddCmfSlN8iUrW5XxV91R37ru25EMI+osQpradSaYSTezPkC07nWSliZfofmpm6GuqNn 81tMo8s4XgA4D5cnYAHrHtW572bf0A5b3dHCBAjhPHZ6hsB3xz0Q58qVwTtmv779P8/x M52y6eQdZkHtTdsmyrngmbH8TDT6bs7huEUI/wjN2pvS9ygv1vWpG55ahcO2ddrztDMF qivQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704276328; x=1704881128; 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=ixHL0u6VBKjtJsv7nsOUJGax3/cXO6U5lzuxjpBvrGk=; b=A30Pm0TugC/YYkYEHWhxAWe71Cl0yY4WjLVLb2dMtL7ON/v4cNr8uoOkjDNxHCa6rb GxdxFNnfl2FJL3ZSYKNYBsIOLZ5A8lE+D8D9Dj72pzQxJDfpg38MxqVyl6Mt3hLX9FAM RLmrQFufjlYLxqQx30a4MH2xkAOOOPcpFLOy+aJTkBmOTeUtQBWJzhNidriGryr3fYGI Qcp0iRazPUPeaAet9bI7imv9Wzz29HIGrEd+IFqwvAsNgZNANDRLld50evtUlyNeTNdZ z6RS6HtMlh8LMsRwOmM4ugKyk3/G86brhLjtQXWQUDKtOBNEpmNjsS8YeeTprsGiZCyl 69tw== X-Gm-Message-State: AOJu0YwIqRZnY7tiL9b0Jbi72+vpRA10xye2c4ufKnNC0oQe64fNc1N8 gV+BdurOkNcdd+XYDvADIfDuN/82bMHTOxLrH8U= X-Google-Smtp-Source: AGHT+IHTJXhUiT0G/mL0iD/EXmLu4dyuplZF9L+0fs89cnLm85gRQqhSW2pnkfxrosJyh0sm89VjXB8ND7LBgXhVqwE= X-Received: by 2002:a25:3615:0:b0:dbd:c1f1:4ff8 with SMTP id d21-20020a253615000000b00dbdc1f14ff8mr9885095yba.44.1704276328247; Wed, 03 Jan 2024 02:05:28 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 3 Jan 2024 11:05:16 +0100 Message-ID: To: Nicolas Grekas Cc: Max Semenik , Internals Content-Type: multipart/alternative; boundary="00000000000024f4c5060e07c10e" Subject: Re: [PHP-DEV] [RFC][Discussion] NotSerializable attribute From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --00000000000024f4c5060e07c10e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =C5=9Br., 3 sty 2024 o 10:09 Nicolas Grekas napisa=C5=82(a): > Hi Nicolas, >> >> =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 flag = is >>> inherited by descendants"), this is very unlike any other attributes, a= nd >>> 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 shoul= d >>> be >>> replaced by a maker interface. >>> Then, a simple "instanceof NotSerializable" would be enough instead of >>> 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* t= o > the class itself should best serialize an object. There, attributes make > sense, because they enrich the description of the class without forcibly > 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 to 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; } Cheers, Micha=C5=82 Marcin Brzuchalski --00000000000024f4c5060e07c10e--