Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112430 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5974 invoked from network); 5 Dec 2020 16:47:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Dec 2020 16:47:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ECF1E1804C9 for ; Sat, 5 Dec 2020 08:15:34 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-oln040092005037.outbound.protection.outlook.com [40.92.5.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 5 Dec 2020 08:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c/zrPayRG9dYERzd4B0ioYvmFt5I6uyJIyVIfAGLlKnAZV99W7AdA+PTs7BF8xxUrCrRZvLFoc0+KGOIeKCID/BcxyO1q1YzQ07w9sKpVMkVZUdeUykfAQs6DgXYqAjJS01RaBCongRmMpVR6kEaMadSzTYluPWTFxFellSVMDYyTbxPc2in6n3tPIwJSzihOUx/GxewIv3+bNLHUInMZKi0gJsbtcepwwG0rZ71W78BYMGfXdYR09wKdV2VuqxmBEfmM4AH73uevu2I8WMlH0A4VyL2+g67XlwPIJiNJX3dvn3cyYEBAmdKZf7cDbQe/lUbrm+VuaSZtBXf2fiWYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PS9rpKtbqXXrBJjwPo1Vimd8AmwcYQea47l4FTDV640=; b=DAm2z6fEkrztidteimQFHcXo9oiE9cpc00Sk2l4LXS4LB13BqxEoshO0jPQjW0aDcRqf584OdRpPkex8p0cIsbeFnHzwUJxBlQB6JmgF2hb7Sj76vWH/J57nfxyf4tBFie/mCVJa6yrdTFh2ZlTW9EK4k+FFyE3HtKnw+sn6nw1sJf5OKDwaZuXTzNdTru0Gbz6z+dA7MrpHZnDMiPMrISzKGYWDSGDCt+c8lQGKQklQx4CpoIcs1+NUpg80EmZF7IvoPntzOIX4YWeMR6t07l8NyHM+UFfAvLdJdUePHZ9zqwz9lfC3XUfLt/enh/9AWCx63/HQeDLBdmv0VO5b0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PS9rpKtbqXXrBJjwPo1Vimd8AmwcYQea47l4FTDV640=; b=F95auD8rNSqjfJ6DpjYEejPkgvzeNaf7hoBO+m+MSzaz2smU7wI8xJIdOsEUei0KQdzCXinPbzWyI4kl/EeJgWJ/we9nWNoHksg0GqVFA/6TsqzBimYNQ3mEtXNaYNAQk6UlZbchwaFW/jdpZJNNnvdbSWM0kiQVL3i5RA7UPMPSjLWUvvCbgYkb4l+BIF8Gq3W4Fr0H73IzxovjtVaV5qSWmLH9NFyfxCRGUdVuZ1G4xOmEeAb3PeNimnr9I0ntFku8BBmogPXRH9I/PuVABoM8k/hQjHzBZLDJfTWHSwbtoTXVQ/IKI35/svDcUw0fohuxJYCM6D7qIIxOXMShZA== Received: from SN1NAM02FT030.eop-nam02.prod.protection.outlook.com (10.152.72.54) by SN1NAM02HT160.eop-nam02.prod.protection.outlook.com (10.152.73.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Sat, 5 Dec 2020 16:15:32 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e44::4a) by SN1NAM02FT030.mail.protection.outlook.com (2a01:111:e400:7e44::114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Sat, 5 Dec 2020 16:15:32 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::d99c:15a8:f595:d00]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::d99c:15a8:f595:d00%7]) with mapi id 15.20.3632.022; Sat, 5 Dec 2020 16:15:32 +0000 To: Larry Garfield , php internals Thread-Topic: [PHP-DEV] [RFC] Enumerations Thread-Index: AQHWypS0dp+yj+uVBEGwghKNxSJW26nojqKAgAANDgCAABBAdA== Date: Sat, 5 Dec 2020 16:15:32 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:87D94ADD43EF6C24884BD6E82322ED944E8AB31901DCAE81DAB10163F9B409FB;UpperCasedChecksum:9B35C30300C096B4C03FF6C1A41BBEAABF82CC265694003483C993E8A8F9C502;SizeAsReceived:7117;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [okQ3pogTzT3pIjZsULCgbdlqibImxSXbNDYga5Qe9c72DuaScp6ro6FqHej70e1Y] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: d5c1c933-b33e-4492-68dc-08d89938fd9a x-ms-traffictypediagnostic: SN1NAM02HT160: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: RMreDdIWyMiEwNaN0zQT9GX0PwxHx4AN1b7rxlDDaULsvu34CJ0T79kjcRQjcaGg6M0UcbYmegLpDjYSlZHyyOmRpBDwTJ8Rs6JiR0W+I/p4mq9VkqKMWMPvYcVKVeM/cSeLp9w6frNvcXiAUZXJra3kC73V7FBrdteCZTJRWJqF+gab8paAdSUMeosnvlRjiKhXqrph3EsDH1SHEAZVdUsOM5sVMYXI47voP5WXVl7b3thNo0lVxhNQqUF0UZSD x-ms-exchange-antispam-messagedata: XFmFFjkWKKn0joY1H7dBlrr158zNmJRW8Vtn8FDiQXrtOr5zcIZLtyRVJke0xRxvCjYtEW1AE8WHJbqpI4mRDqNtpH5fG6hZG/fRU7gAHLIljRXjIQCKYBfElz/8D6yY6sVseapzBLQJo7uMO1zp0Vr0+MoyNQXEA416Wb2mpA/zhwGVbQOKauNirp1GHiB+tt5MWa4hYUMFxcMiB9+DDQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT030.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: d5c1c933-b33e-4492-68dc-08d89938fd9a X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2020 16:15:32.4218 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM02HT160 Subject: Re: [PHP-DEV] [RFC] Enumerations From: tysonandre775@hotmail.com (tyson andre) Hi Larry Garfield,=0A= =0A= > Right now they'd do the same as objects, so they'd serialize as an object= .=0A= > Unserializing like that, though... hm, that would probably NOT still be = =3D=3D=3D due to the way PHP handles objects.=0A= > That's probably undesireable, but I'm not sure at the moment the best way= around that.=A0 I'll have to discuss with Iliya.=0A= =0A= At a glance, it seems like it's doable in php 8.1 internals to make the uns= erializer return a singleton if you override the C `unserialize` callback o= f the class (this could introduce edge cases during unserialization failure= for destruction, expected to be solvable).=0A= This would require using the `C:` serialize() encoding (php uses that for c= lasses implementing Serializable), not `o:`=0A= (unserialize can be set to a generic C function that creates a value and pu= ts it in `*object*`)=0A= =0A= ```=0A= // Zend/zend.h=0A= struct _zend_class_entry {=0A= /* .... serializer callbacks */=0A= int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, ze= nd_serialize_data *data);=0A= int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char= *buf, size_t buf_len, zend_unserialize_data *data);=0A= =0A= // ext/standard/var_unserializer.c, in object_custom()=0A= if (ce->unserialize =3D=3D NULL) {=0A= zend_error(E_WARNING, "Class %s has no unserializer", ZSTR_VAL(ce->name))= ;=0A= object_init_ex(rval, ce);=0A= } else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (z= end_unserialize_data *)var_hash) !=3D SUCCESS) {=0A= return 0;=0A= }=0A= ```=0A= =0A= (I'm one of the maintainers of https://pecl.php.net/package/igbinary , an a= lternative binary php serializer)=0A= =0A= - Tyson=