Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:125439
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 qa.php.net (Postfix) with ESMTPS id 802F31A00BD
	for <internals@lists.php.net>; Thu,  5 Sep 2024 16:31:13 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
	t=1725553991; bh=6InC0O77tpKIXGEkHFE/MBUaI2md3GdliZ0D+OB1UFg=;
	h=Date:From:To:In-Reply-To:References:Subject:From;
	b=P5e6s7eAEAE6HSvcGSm0D6dlwFHVy78Iz/Y36VFOXPsLOBKEAmG2a4TP4gl8RSiRd
	 wlHpYKAym4HIKEbRZsn5j1Nb2HRU6RcqXzY2BhuTZyn7f6yccElDZ01mC1wOO5ght4
	 acxmGaEM6NNL0yWo0wsMwvNCiPlQh4DVhh+8mzNlmEjYwZR+dpqd68g2Mz+Qp1zgal
	 JPs/ENS9tSoTV0THt8lo6EsqWszj8gqJm6Ws0jskqXahKIT109B8BJXVqDgx176Sih
	 aQ4p/XmuzRTsDm198apTRyuCnQY1kGor39z9rM82aOXCYufb9MvtI39emhllsScFGG
	 abmWGzs8OrDhw==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 721D318006E
	for <internals@lists.php.net>; Thu,  5 Sep 2024 16:33:09 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net
X-Spam-Level: 
X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_40,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE,
	RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no
	autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From: <imsop.php@rwec.co.uk>
Received: from fhigh1-smtp.messagingengine.com (fhigh1-smtp.messagingengine.com [103.168.172.152])
	(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 <internals@lists.php.net>; Thu,  5 Sep 2024 16:33:08 +0000 (UTC)
Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43])
	by mailfhigh.phl.internal (Postfix) with ESMTP id F2360114016D
	for <internals@lists.php.net>; Thu,  5 Sep 2024 12:31:09 -0400 (EDT)
Received: from phl-imap-10 ([10.202.2.85])
  by phl-compute-03.internal (MEProxy); Thu, 05 Sep 2024 12:31:09 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc
	:content-type:content-type:date:date:from:from:in-reply-to
	:in-reply-to:message-id:mime-version:references:reply-to:subject
	:subject:to:to; s=fm1; t=1725553869; x=1725640269; bh=2duzAnvCfM
	UZ9r1YT6ObwmJTrt3DewApnFWf9ArbC2w=; b=iK6oIbzDQAhOx9p92d6CXpWdY8
	BdWkx36SSk+5Sxs3kxgF6HnVATorA5sEi9ISEg8uNh9+mC2whzl5d4huFDXtrMvj
	mDiX5zWppLN38osHKScP3cNZ3p8/SD5y1Gr6vUBAXkqiGHi/kye4CsvhZFuwdxQW
	wRb5NH39uxxX08e9e9Ys1xS+EbD6nZvwlLcDa6ZlmfWHub9xYVEKYAyiw1CLevTz
	NV/6M7MkCh9H9BFzZ+wcTwE0xBM0Qmk+4b25/7H6h+2gXRxaeqxYFKcYRBib3jhs
	BluZS4C1Cb2RjuUe7LuI7lDKncIfExQTWJCrUVkp7axjkTWTp53LF+lnR8+g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
	messagingengine.com; h=cc:content-type:content-type:date:date
	:feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
	:message-id:mime-version:references:reply-to:subject:subject:to
	:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
	fm1; t=1725553869; x=1725640269; bh=2duzAnvCfMUZ9r1YT6ObwmJTrt3D
	ewApnFWf9ArbC2w=; b=pEoS5S/RvTdlJ08s1I3GOgLjDnF+6WxSv8yAkSwoPOpZ
	jFfGgvwvCVLeHlYlYB67BQNq5lXZ6trNuo01PGy8wH4HjNV+MG5Yr5mTlSosjIx4
	ef4D/9GRJNSIZJjBSm7Z0SBhslmf7PxzTlTM0mgW3tdgNyG6fUqwmwxH/wnwvyRa
	pwelb9ETLsd70nuVXFRkgYoV9W6kdbgOxaOIjK9BYbe/eVA5E3lTUDd3D6+6WuVv
	6NYYTiXSwnInUqtCLBeIn/Bl9bEFCTpA2FcKexoGTf1btwSVSkPqwKF34A7MCki5
	HK3j1m8v8quIAfqvlNLQUrufBUxXB8vS7bngD6Almg==
X-ME-Sender: <xms:zdzZZo4kyHDueW-ukBkWWv23iOZIHPSE3oPuLuLHCgy7t1Fo7KA5eg>
    <xme:zdzZZp5A7fSK5lv5ZhFlq3eS4FtLNyE0WJsdSYo_jdTSD-nMecMs-r4wocPjIICp2
    H_LIaXuKMN-ItZO960>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudehledguddtvdcutefuodetggdotefrod
    ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp
    uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepofggff
    fhvffkjghfufgtsegrtderreertddtnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhn
    shculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenuc
    ggtffrrghtthgvrhhnpeejveeggfejteeiledttdetfedvtddvieduleejgeeghedtgfdu
    tddtffektdelueenucffohhmrghinhephhgvrghprdhsphgrtggvnecuvehluhhsthgvrh
    fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshhophdrphhhphesrhif
    vggtrdgtohdruhhkpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprh
    gtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght
X-ME-Proxy: <xmx:zdzZZnfPGv6CuCZ3wJ8q-wgPavStUlYEE1d0rpaWI9miUrPTR63kTg>
    <xmx:zdzZZtKrZgAqvzcn8psiWH1LGFL2l75xbceaZof2tknFHfJYIj5FTg>
    <xmx:zdzZZsKY8ScGz8xKtIOVXDsaI0KT8grCfUpw3ilDwy8VjDgOX2vclg>
    <xmx:zdzZZuzy2qADR6R3X-gPSBcfqxZmKZDo5wnND3-HM9xEAWpbR5zQQw>
    <xmx:zdzZZmzEz3XpmIBkeh_7I8vpLJ5atIMUiJO5iqDcOybMc20Hs2mfP61F>
Feedback-ID: id5114917:Fastmail
Received: by mailuser.phl.internal (Postfix, from userid 501)
	id 90EF13C0068; Thu,  5 Sep 2024 12:31:09 -0400 (EDT)
X-Mailer: MessagingEngine.com Webmail Interface
Precedence: bulk
list-help: <mailto:internals+help@lists.php.net
list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net>
list-post: <mailto:internals@lists.php.net>
List-Id: internals.lists.php.net
x-ms-reactions: disallow
MIME-Version: 1.0
Date: Thu, 05 Sep 2024 17:30:24 +0100
To: internals@lists.php.net
Message-ID: <1adfd0cd-416e-44e6-8d4b-7061a31199b0@app.fastmail.com>
In-Reply-To: <98553A91-FD3F-4E1B-91D9-D8B00CAD5FC5@getmailspring.com>
References: 
 <CAGKNXQG32aF58gPnf1ywbmde72F_Wwjib0oXhN_ve6336RnQXg@mail.gmail.com>
 <98553A91-FD3F-4E1B-91D9-D8B00CAD5FC5@getmailspring.com>
Subject: Re: [PHP-DEV] RFC: Deprecate json_encode() on classes marked as
 non-serializable
Content-Type: multipart/alternative;
 boundary=4b033b411f5542de9e11783381541924
From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]")

--4b033b411f5542de9e11783381541924
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Thu, 5 Sep 2024, at 17:03, John Coggeshall wrote:
> I would suggest we take a step back from this and look at it with a bit more of a wider lens. It seems to me that this would be a good place to have an attribute (e.g. `#[NotSerializable]` )  that could be defined for any class (with `ZEND_ACC_NOT_SERIALIZABLE`  being automatically given this attribute)? It just seems to be a more holistic approach that makes sense, rather than basing it on internal engine stuff and/or limiting it to internal objects.

It's really the opposite: if we had an attribute, it would be used to toggle the existing internal flag.

`ZEND_ACC_NOT_SERIALIZABLE` is just one of a long list of class, property and method flags which the engine uses internally. You can see the full list here: https://heap.space/xref/php-src/Zend/zend_compile.h?r=58aa6fc8#212

You'll notice that includes things like "final" and "private", which refer to straight-forward syntax in the language, as well as completely internal details like "preloaded". It also includes ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES, which is the flag set if you add the #[AllowDynamicProperties] attribute on a class: https://heap.space/xref/php-src/Zend/zend_attributes.c?r=5a18279b#validate_allow_dynamic_properties

So if we had a #[NotSerializable] attribute (which I agree might be a good idea) it would be implemented by setting the `ZEND_ACC_NOT_SERIALIZABLE flag on a class definition, and `if this RFC passes, it would automatically apply to json_encode() as well as serialize().

Regards,
-- 
Rowan Tommins
[IMSoP]
--4b033b411f5542de9e11783381541924
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html><html><head><title></title><style type=3D"text/css">p.Mso=
Normal,p.MsoNoSpacing{margin:0}</style></head><body><div>On Thu, 5 Sep 2=
024, at 17:03, John Coggeshall wrote:<br></div><blockquote type=3D"cite"=
 id=3D"qt" style=3D""><div>I would suggest we take a step back from this=
 and look at it with a bit more of a wider lens. It seems to me that thi=
s would be a good place to have an attribute (e.g. <code>#[NotSerializab=
le]</code>&nbsp;)&nbsp; that could be defined for any class (with <code>=
ZEND_ACC_NOT_SERIALIZABLE</code>&nbsp; being automatically given this at=
tribute)? It just seems to be a more holistic approach that makes sense,=
 rather than basing it on internal engine stuff and/or limiting it to in=
ternal objects.<br></div></blockquote><div><br></div><div>It's really th=
e opposite: if we had an attribute, it would be used to toggle the exist=
ing internal flag.<br></div><div><br></div><div><code>ZEND_ACC_NOT_SERIA=
LIZABLE</code> is just one of a long list of class, property and method =
flags which the engine uses internally. You can see the full list here: =
<a href=3D"https://heap.space/xref/php-src/Zend/zend_compile.h?r=3D58aa6=
fc8#212">https://heap.space/xref/php-src/Zend/zend_compile.h?r=3D58aa6fc=
8#212</a><br></div><div><br></div><div>You'll notice that includes thing=
s like "final" and "private", which refer to straight-forward syntax in =
the language, as well as completely internal details like "preloaded". I=
t also includes ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES, which is the flag set=
 if you add the #[AllowDynamicProperties] attribute on a class: <a href=3D=
"https://heap.space/xref/php-src/Zend/zend_attributes.c?r=3D5a18279b#val=
idate_allow_dynamic_properties">https://heap.space/xref/php-src/Zend/zen=
d_attributes.c?r=3D5a18279b#validate_allow_dynamic_properties</a><br></d=
iv><div><br></div><div>So if we had a #[NotSerializable] attribute (whic=
h I agree might be a good idea) it would be implemented by setting the <=
code>ZEND_ACC_NOT_SERIALIZABLE flag on a class definition, and </code>if=
 this RFC passes, it would automatically apply to json_encode() as well =
as serialize().<br></div><div><br></div><div>Regards,<br></div><div>-- <=
br></div><div>Rowan Tommins<br></div><div>[IMSoP]<br></div></body></html=
>
--4b033b411f5542de9e11783381541924--