Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114132 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17961 invoked from network); 24 Apr 2021 17:20:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Apr 2021 17:20:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 462BD1804D8 for ; Sat, 24 Apr 2021 10:24:24 -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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,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 NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08olkn2081.outbound.protection.outlook.com [40.92.46.81]) (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, 24 Apr 2021 10:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D2ebLwvYHGkJ6oi/no1NvFKPZqBr10XjSR7MpCUDWBnIBt9d6XV35w0SUhvXJtTDWVC4kYjVLUDxOKxhOeHRXdlj3g8S/UFBWZ56G9t226iydC+yKBJdlV2AYkLwQVuDon9723PCwrYPGFbaoxZw0BEV7+wzadIEzLV7FJ684vRdJqCQYhL+YYF0j1FL6YrZ6uqirGgKf2HnoRb97mhVmufKQS+um4bXNgHqTgvzbN+vDe7uOM7nG7dhcixz1BGC4vgY6UxZnNGCSffnqDx6dba4IcyMKO5rnWj6UFF0tp8BCbw8+ERO1Muw9kvTCj6CkGL5sJMKkiRA/h9av28DcQ== 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=XOj5iVjVU5jnhuNLjOU7Ck1cgASY3fLDkO3qP2vbb2U=; b=ft2cz7ktT/P2EMwmM5P8NClj60+FzJvBHdAT2oXjHFlpXTJLIqotNgMTls+bK8OwC32Lz5zT7eGjKxhvLbx4UGDRZ+yn99jARnaE/b3Mlf4EzDQGhYWxsQy9s8bhFnipomu1fhvUUn3l/axruGvBwcqDp4b8Lf4PJCc6ZG0cjZ3Lw1mFoqParEQI/UiWbaQIOgcbPrxoNRwnJrvdxf3g6PJaCL+MiwQYPIuCyT87IJIKz1VRS8YLI1N/twJkt05v5WqVDAfZTYwbi+ElSRQh3ChaiOEdaIpQePD3Ia/E+rb/tm5ROTJdNFjYQbyEbyXx+j6nsWln07/sup03PsJC9A== 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=XOj5iVjVU5jnhuNLjOU7Ck1cgASY3fLDkO3qP2vbb2U=; b=K/7tqDTrR0OekJCwBgwyua5aiRSobj/WjAjBDXYE/QGZ6zhg+gLOBaYJry0Gr9wGH00auHe+ghxeNVwXvAMeF0z8dbtTzLyIGp5Iv3V20g/V20EcFSEw8WPpJACFsqjFdIR3lXSSgAQ8sZybBI/b00U48NJ8i/4z+t55Juwpd4U/H9aKMYtvPCGh0dwDMta1QVuleM1pNEajMP/Yo2qQdiLR7t2gcc/hb0CaKjrEQfNnX47n7KDdfi73qhbwgBQ49A3ug5loYg/+o3PM1iwjlIKFP8nQGuGZnoeYOszwX5kDRfelYZFbbYWJlz3z/BeMF+S/bq8UmP1OjSONJqIOGw== Received: from BN8NAM04FT032.eop-NAM04.prod.protection.outlook.com (2a01:111:e400:7e85::41) by BN8NAM04HT042.eop-NAM04.prod.protection.outlook.com (2a01:111:e400:7e85::420) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 17:24:22 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e85::4e) by BN8NAM04FT032.mail.protection.outlook.com (2a01:111:e400:7e85::266) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 17:24:22 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::9c7c:2273:6416:6a0b]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::9c7c:2273:6416:6a0b%6]) with mapi id 15.20.4065.022; Sat, 24 Apr 2021 17:24:22 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] [Vote] Adding return types to internal methods Thread-Index: AQHXN0sQDOXF4BnTpkyjI+fKo2GPt6rAKyIAgAO81wI= Date: Sat, 24 Apr 2021 17:24:21 +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:4A7B57FC0378D600BEB3A9A7099446AF6B82481DDF9BB0E87A28CB8C400F90C1;UpperCasedChecksum:2CB07DE0388ABF9B753CA6E65C7952D68C704C1FBE94AE754F98AEB4A6524A80;SizeAsReceived:7140;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [EtFtXbB23fb4xlsIJAlIo252g3+8yECCSlqinZmsVcLcLxfhbyGt6vgiEwTmVQiU] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 1a6ae933-2dba-4735-4e1f-08d90745ccd4 x-ms-traffictypediagnostic: BN8NAM04HT042: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6ah0zadrr6p3cB4S4YlB+gx+tQHK4oMhS63EwzTZrKTexXmo/Zn/vzEvqx4nEewN+e57fxApJdNxOozDMexFV8xNN5R3K31tndbXQExtBsOCe379TBfbZt3hM8gnbRNjsA7AWWdCkrgW6la38asxvyg0ePUFoQ57AxDmI50RsrkcLY9tO1MfeIU2TRXKT7cgSrCbV7CXsWFp04UttwCBjrIVAtWTGK0Oo3aH2V/zKEl+IZIsehysFyvfoC6CUibUjp4nMZNy7lqhfr9tjI/xEDQk+o4+bo30P8+H2m7lpwZLPdhlwPX2xN48VFhoQZSfmRkzScMKOcNj17rg2jXWcdwjod8t5VjTTCeC0HVv1sRxztAyRmDz+zl77eoZnSR7cNf3iv8FiZ08MDnjPsgSS1bUE9t+OQBVDSoZZfnYUd8= x-ms-exchange-antispam-messagedata: xaa5nFHOrd+u8mRfobnElMGcmTp/OjV/nLsr8M9Y533zkf/aFfTtKhACITsD+GkmPTpkT2gtvuVLCKOK1J8UIa2winTJlllh5coQXCZvUDQYTaxVGD5w9WFv+YCfh2Yfg9+XX6fX+Ihxspn19EAfkL835/d94T0WEBy9qiOuDCZCcO9fxRmRLfDfTnjzYpCR6q437/MW0Z8wl3wwc6Utjg== 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: BN8NAM04FT032.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 1a6ae933-2dba-4735-4e1f-08d90745ccd4 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Apr 2021 17:24:21.9179 (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: BN8NAM04HT042 Subject: Re: [PHP-DEV] [RFC] [Vote] Adding return types to internal methods From: tysonandre775@hotmail.com (tyson andre) Hi Marco Pivetta,=0A= =0A= > In fact, if reflection were to switch to the actual runtime return types = of=0A= > those methods, I don't see a reason why downstream consumers would break= =0A= > (stubbing tools, code generators, type checkers, dependency solvers, etc.= )=0A= =0A= If the published library/application had to support older versions (e.g. ph= p 7.4),=0A= but the tentative return types contained types/syntaxes that required php 8= .0 =0A= (e.g. union types such as `string|false`, new types such as `mixed`/`never`= , etc,)=0A= then the code generators and type checkers and stubbing tools would need to= be =0A= updated to exclude the new tentative return types much earlier than absolut= ely needed.=0A= =0A= - Users would benefit from code/tooling working the same way in php 7.x and= 8.1 when upgrading to 8.1=0A= and making the tooling unexpectedly stricter may be regarded as a breakin= g change by end users, especially for unmaintained tools/libraries.=0A= =0A= =A0 I'd prefer if the tooling authors and end users had to opt in to use th= e tentative return types=0A= =A0 and upgrade to a version of tooling that was aware of the tentative ret= urn types to start using them.=0A= - Forcing getReturnType to change immediately would be a barrier to upgradi= ng, especially for users that aren't deeply familiar with php, =0A= =A0 if the php version or library versions being used in production weren't= compatible with the latest versions =0A= =A0 of those stubbing tools, code generators, type checkers, dependency sol= vers, etc. that were aware of tentative return types=0A= (e.g. a test mock no longer returning null)=0A= =0A= To upgrade from php 7.3 (or older) to 8.1, a user may want applications a= nd libraries that worked the same way in both 7.3 and 8.1,=0A= and would only want to upgrade the applications/libraries (and fix the te= ntative type notices) after they stopped using php 7=0A= - PHP 8.0 would be only one year older than 8.1 and automatically generatin= g more user-defined subclasses with union types=0A= =A0 this early on (e.g. and publishing to packagist) would be inconvenient = for users still on php 7.=0A= =0A= Also, as mentioned by Nikita Popov in https://externals.io/message/113413#1= 14052=0A= **Having a distinction between getReturnType and getTentativeReturnType als= o allows the functionality in this RFC to be extended in the future,=0A= e.g. from a getReturnType of `BaseType` to getTentativeReturnType of `SubTy= pe`, rather than only being useful when return types are missing**=0A= =0A= Additionally, I agree with the points made by Nikita/M=E1t=E9 Kocsis - olde= r releases of static analyzers would treat getReturnType as if it was defin= itely the real type,=0A= and falsely treat some type checks as **definitely** redundant/impossible r= ather than **probably** redundant/impossible,=0A= leading users to remove those checks with insufficient validation/testing/r= eview, before it's definitely safe/correct to do so.=0A= =0A= - third party code in vendor dependencies (and mocks generated for unit tes= ts) are typically not analyzed for issues,=0A= =A0 but third party code might override internal classes and make those see= mingly redundant/impossible checks actually required).=0A= - E.g. if getReturnType were to change instead of adding getTentativeReturn= Type,=0A= older releases of `phan` with `--redundant-condition-detection` would fal= sely report that conditions were definitely impossible/redundant when it is= still possible for subclasses to return different types.=0A= =0A= (I'm a maintainer of the static analyzer http://github.com/phan/phan/ and w= ould personally prefer the getTentativeReturnType approach,=0A= Marco Pivetta(Ocramius) works on/contributes to various php projects/analyz= ers such as BetterReflection)=0A= =0A= Thanks,=0A= -Tyson=