Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115816 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87761 invoked from network); 25 Aug 2021 13:52:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Aug 2021 13:52:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 11A0118050B for ; Wed, 25 Aug 2021 07:26:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FORGED_HOTMAIL_RCVD2,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,PDS_HP_HELO_NORDNS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, RDNS_NONE,SPF_PASS,T_SPF_HELO_TEMPERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.80.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from NAM04-MW2-obe.outbound.protection.outlook.com (unknown [40.92.46.87]) (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 ; Wed, 25 Aug 2021 07:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A3SE+foji/WojSHMoFgerClUDtiwniwskUeDj4zpOMHxIQ00/DG3TUQqx5SZW2CqsNhM1JMOZOjneglsBo4Ca/YwsJVBbKhBeUnhMvDnNz3v862931C00q2JcrrSCfquA3w/b5F0rZLfoKRiUjeNWJcCClwRF5UCHIkv3oRb6h7u+nkOOB3kmuPelptMKZSjv51tI/0b1pw0DC/0bXg8ESqqOl1df9uKNrA8jyKfUmU93w+F//iYjwvBnxWZkBP7QXjJ/d9cbJT/bHg4AFVGZLbjJcjQGY+FzvNY3vhLbPHmga1bCeEXpvndNjFFj0VQTwLSw3mH8DlrQncHUBk5AA== 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=6b3VnapvkmzZcEjFiGuBW0jKmuRLwKNRfO5gr17VCrI=; b=M+goDgKypCWi1IoFSzABdh60Md084j1KeF+2CfHWM9EzuvFyYUUw+HgbizMoowSp2teYhG7fa4GpEFgUns7dLSJcOfWlZseR/mH5LiIwqv8dEbZ97ji9Id7oX5YGMPjb0mpmCG+Hj1YM57i7QS0IG/DcIbFVSva0zdaR4MxzL702KEQDN6JTJeLEqqvtojU/yYGuIeDDUWmAcVOvQsD0MNqlrJfC7qWRdvRbVhuEx3pws3tm4Kix8mAUSjM5YBH9aag4u+gk/OceVaZ21EH2pT9qk7UVSWDOvp3KU2NPboU/1MN+xV6a3OGAJFPmb+1xcyxNUFVZs0KtSRYkhzqYqQ== 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=6b3VnapvkmzZcEjFiGuBW0jKmuRLwKNRfO5gr17VCrI=; b=luZ5YbXMr/5s+XXKQgaKPzKegdciNgqHb4zDtR4pyU/bzVb/C7CiF4bbVAUtT0nBr/sYHESg05L2EgWGOepUrMgnjuUIa4ZA15h+pJtEhySnyymaqgZi7abagQ5RX1QU8p1uG4CaYdky86XHQ74bu0XOVIZbyxSbHFZuUs6qDZsHA+Ct07ilhdG2+7a79wlzot58e6hWr/+IxCGnCJmumChIRoeiM3HuCpDw7Uq09w/fJz0eDLK7kZikZaVUTgiagYNpArGr7+c8jU/jG3RzH+L5TcnFI95O3ETEUeoYd3kgR2pcgnnyBrbj6PDY+zCQakQi4HczpjYRKpfKgvgFIw== Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2603:10b6:5:1cf::26) by DM6PR07MB6506.namprd07.prod.outlook.com (2603:10b6:5:1ca::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17; Wed, 25 Aug 2021 14:26:12 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::9dbf:271b:5e16:dc88]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::9dbf:271b:5e16:dc88%3]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 14:26:12 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] Deprecate dynamic properties Thread-Index: AQHXmZhyAqhVJ2OBOEmOZSZ0AmWdj6uEPzhQ Date: Wed, 25 Aug 2021 14:26:12 +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-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [dFEyN4n7g65mR+kQ9E4YN0WTNds1zu2yiSuhTyUdMBx1izBAN15f0YKklRxE/rLq3l7bz0/ODhM=] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9f048c23-1593-44df-f82e-08d967d44a25 x-ms-traffictypediagnostic: DM6PR07MB6506: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: a8/5c/RKGTXFQ8WGm4h0SRIFQNJsR5nmaBnwmQScjwY2w54d1J7Hg7azBzGrUUC/0lsecGOTn0tWnE/r6ERFeZ8wy7Qt+iKzWYCYXIqfFbnZhKLBp054YOfTtwkkV6xgKo7LeBl2aFciuDR6Vw7pRTsGOqCiLO5txdVNrtB+25DBNSBeG12m/RJ1hweGDz8RV727c4KVrYp9iFaelUaIDMB6FvW6oZeIgdBnr7VCCqU8hMO2XZrsiMtcvudSS7sNYXoEJ/uXEH/6QobeiCSOiD9VVbKrnyc5kZABwlfIzkZG+NJvITYORk/iR4rgGTcNAIYHFSTggzHSLXZJj71z8hqVePX8rBz8QYMbCweWuF5S16L3o0kzSunpnu3s38nFSokBlO3N8phQHEa8vUb13Ix2btyN8KLRZDh1d5C0xIhVK1ShFd+yvKvUVhpRrI4fy2h/3dU/DXpYjFiobWTsxsICSmrBo5R/DOVCJhzZfyE= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: HXTTIKwu06+8/F3G7F3D4Np4MTLbZi8y2RWY5Jy4uW+Jh5obWzU/PhWJC67Q+GWbmFEbPvSw1E3/bY8/JgCS46aS/u8F33z0vO0lKVbWsfmJKtYV0cpTHBJZz3IJMO04BKq/4lj5xUX9SzA0X59AXVJkh4yq5e0dg57XDHKWcujAworv4/HEVbSwOQAyml7WfcVD/TirgWZapqEFbMII/g== 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: sct-15-20-3174-20-msonline-outlook-35401.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR07MB6618.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 9f048c23-1593-44df-f82e-08d967d44a25 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2021 14:26:12.3926 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted 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: DM6PR07MB6506 Subject: Re: [PHP-DEV] [RFC] Deprecate dynamic properties From: tysonandre775@hotmail.com (tyson andre) Hi Nikita Popov,=0A= =0A= > I'd like to propose the deprecation of "dynamic properties", that is=0A= > properties that have not been declared in the class (stdClass and=0A= > __get/__set excluded, of course):=0A= > =0A= > https://wiki.php.net/rfc/deprecate_dynamic_properties=0A= > =0A= > This has been discussed in various forms in the past, e.g. in=0A= > https://wiki.php.net/rfc/locked-classes as a class modifier and=0A= > https://wiki.php.net/rfc/namespace_scoped_declares /=0A= > https://github.com/nikic/php-rfcs/blob/language-evolution/rfcs/0000-langu= age-evolution.md=0A= > as a declare directive.=0A= > =0A= > This RFC takes the more direct route of deprecating this functionality=0A= > entirely. I expect that this will have relatively little impact on modern= =0A= > code (e.g. in Symfony I could fix the vast majority of deprecation warnin= gs=0A= > with a three-line diff), but may have a big impact on legacy code that=0A= > doesn't declare properties at all.=0A= =0A= I'd had some concerns.=0A= =0A= It might be too soon after your addition of WeakMap.=0A= https://www.php.net/weakmap was introduced in PHP 8.0 (and WeakReference in= 7.4),=0A= so applications/libraries fixing the deprecation may need to drop support f= or php 7.x early.=0A= Applications attempting to polyfill a WeakMap in earlier PHP versions would= potentially leak a lot of memory in php 7.x.=0A= =0A= - I don't know how many minor versions to expect before 9.0 is out=0A= - Is it feasible for a developer to create a native PECL polyfill for WeakM= ap for earlier PHP versions that has a=0A= subset of the functionality the native weak reference counting does?=0A= (e.g. to only free polyfilled weak references when cyclic garbage collect= ion is triggered and the reference count is 1).=0A= =0A= Additionally, it makes it less efficient (but still feasible) to associate = additional fields=0A= with libraries or native classes/PECLs you don't own (especially for circul= ar data structures), especially if they need to be serialized later.=0A= (it isn't possible to serialize WeakMap, and the WeakMap would have fields = unrelated to the data being serialized)=0A= I guess you can have a wrapper class that iterates over a WeakMap to captur= e and serialize the values that still exist in SplObjectStorage, though.=0A= (Though other languages do just fine without this functionality)=0A= =0A= I'm not sure if a library owner would want to change their class hierarchy = to extend stdClass (to avoid changing the behavior of anything using `$x in= stanceof stdClass`) and the attribute/trait approach might be more acceptab= le to library owners.=0A= E.g. https://github.com/vimeo/psalm/blob/master/src/Psalm/Internal/Analyzer= /Statements/Expression/Call/FunctionCallAnalyzer.php =0A= would set a dynamic property `$stmt->pure` in `PhpParser\Node\Expr\FuncCall= $stmt` in a vendor dependency on php-parser.=0A= =0A= Regards,=0A= Tyson=0A=