Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122093 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1092 invoked from network); 3 Jan 2024 10:10:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2024 10:10:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1704276689; bh=/Am2jAigGFPYQHsajG3XXqIxhwNqjhJ6V1YfuJcE6TQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MbfM+n1ajYgeKtZGYo7q6l0xo8lHRhZaZvQbiJrsVMmykoZ8y1OPgbSpyTDgpo3u5 hdcz6Pws3179tCTddPXQf1F+51S9+5DFGwUmp2X7JxJTJFNollZVY62Ha4CyGfgDHD kD4/gRA7TnEBWzEpwHRBPUesan+hcOS7LcPkXeCWR7Z22n3MvCHTVDD2z11CdqBHJ9 4PQK/bVn6KGr6v84XY0KX1LtmltiVPYI9DoePSCRDxkvfag2mWrUGmjKsdSjX4Vknw QbW5MnWDICFLEEZauBLOtaTYl8eKmfRpMU2bSmLYfixuvLJYjrlelp42mXqNpG+iic xYG4QQFDUpBRg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9DD79180054 for ; Wed, 3 Jan 2024 02:11:28 -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-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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:11:28 -0800 (PST) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-50ea226bda8so1150133e87.2 for ; Wed, 03 Jan 2024 02:10:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704276656; x=1704881456; 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=eSFjA4sPxijz9QLVQR5EGeYMNHXKlwbly1I0DmIRbj8=; b=IXcjyFnXY3OeTu8RQFUATFcgjR2uKcjMgnJNHpB8cjXkIu27hmuR+ZvOsPfILeKZlk YdhySjI2+LYS4bDIKp4IzlOdAdbBjZiEt8EKf168jnAb7rFSS0SkVjQYEOY/oqufUBSl 4R3TvrozAyVukIxwJzg+9T0XKu4Yb80raBgzzuhXaI89bPAYJMVVQtVZm4FvouV3YQ2m J0fy+VWYEP4g9msVVJfCKr2btDsdhiLDQpDregr2Y/IFtXbuax9Wmogyj2NEEXauTz8R b+aRxqC/wMiCuSqnE3co5oK05v38HXeUYYtkw7wSyFkHX32oy7lob6FujMBuE/NWmHbd LdmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704276656; x=1704881456; 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=eSFjA4sPxijz9QLVQR5EGeYMNHXKlwbly1I0DmIRbj8=; b=XfpYcobYTWK9Ho0VP8VU3BvztShW4emJIoM+XoAjX/Bq+Wa/wV4gG5T5VPtFeA/Gmc 0NdeAVLOY1o8RHEUo9zJlmtrwdQ1DmUocynaUepT2WXkea7xn3MljrAcLNOJ9OcwQPYY Hse2BiOB88/s1qL8knrSJdR/YS/xEF+IRzcVY2k8cpPVwHY47RpK+R3HdbGUzzSResCd PDbKg4BPLx0Hdr+WJHTFRSgBKC5ts7hAEEXlQY/LBOwPFnlRNOEKh5+bpHP82qtLPsbl KOuC94dON8Dhfa/4yA2w8/gX1yGA07Rt3c+V/RxBDcOSO6aMq2p7dZPnf6x5kEJBb57S XA2A== X-Gm-Message-State: AOJu0YzONscGTo/Ov2BWTWw5x80V4zLzVIANHMV29Aq3RHRPAlZFtP84 6Wx0AsxYBRzK2kwpyIc+MgOtH8SUa0dsnKPJsQQ= X-Google-Smtp-Source: AGHT+IG87URzKCReVpWBodezra5mA3sJ3yzvAFlN7SJoTGaVkidvZZZ++Shk+YvVgZUHhQjIws2kpLYrN8pvMWA8TWc= X-Received: by 2002:ac2:5f88:0:b0:50e:3d6f:6e20 with SMTP id r8-20020ac25f88000000b0050e3d6f6e20mr7890965lfe.84.1704276655642; Wed, 03 Jan 2024 02:10:55 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 3 Jan 2024 11:10:42 +0100 Message-ID: To: =?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?= Cc: Max Semenik , Internals Content-Type: multipart/alternative; boundary="000000000000a89b07060e07d4e6" Subject: Re: [PHP-DEV] [RFC][Discussion] NotSerializable attribute From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000a89b07060e07d4e6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > >>> =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, >>>> 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 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* = to >> 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; > } > 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). --000000000000a89b07060e07d4e6--