Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114140 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39037 invoked from network); 24 Apr 2021 20:37:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Apr 2021 20:37:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B62BC1804CC for ; Sat, 24 Apr 2021 13:41:03 -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_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 NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2098.outbound.protection.outlook.com [40.92.42.98]) (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 13:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SjOElskWtSOtDiJ+2+AMEtFQVZ77drk8Q75Vfx/FYALI0PJvLnVsKYMOZ6XX4Lrc/dbxmhbn4U+VF4WJgRrEDGxh2CWQqo8c7HjHu3NwbCKRB5eBYCHJSUZafHxeWav0qqxtgY2puT0lRn79eIXOUfqXPFPwY7OgHFt8EWnHDLtvqBcWLolaVyOF8JM1vJ/TjKHSiNWOaiuYQDSTEfshHVVJQJNkSN54ygTbNy3O5frinc9dv7H8Pbj12FJHtXa7J2EgRIImXaL/sFORnXHwIymAFJO6J32HyDedADWJkUG691K8GaIO2jwU6czR5ZSKBjxBeyqw9M6ebUF1avy1zw== 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=wSEimBHNcdHc65A/qQSmpjL17bKkKN9uDjKRP2vnh/M=; b=BfRUIgbdp2dLZaitnG4hBjqLqWI+VnYc4BiudzmmRaT46ZuDuu7ftpi5PHS67R1e1o3tjqFupHuTN3n1NxvyNQcBeYeI0R1nzkkjNOjcKr3QIKqpx4/B8tofmtte5NMI9sJHEGFBd9QjjYFUZGupArfjIR+OVjOCprpI7TVluKH/ln2z3VSHzBchmMsf8ASI055UKUaIMBJVjcj20MokPJvmQ+eMpM2WDDB1LaHxloUIwziDHUqF3qdRpZMJM8QTgnt+wCUk2G31awYWwwTAfnYRtcAJnZOsbQzJzXKkgzOAqbqt/mTss8LjUI68UYm1lYrFNfqnW7mnzhKGtAlHfA== 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=wSEimBHNcdHc65A/qQSmpjL17bKkKN9uDjKRP2vnh/M=; b=K0fQzsghjaAzZToYJYCAiPKhbAoYfNfRQPYaxGrpXJZScZSSW9sYKSDuN5ioxOqZUDVcJMHvFYw4jiOr3FNKanZwF08zQPxcusavZ6xgzoQdI3FkxyXqGOEII7Z9EYDJmY+mEhENMAhysUH8d+C5GCn1U41VRZOLa+oVpCZdvNQx64z4zBHPdyKMwNrBrPblkKcPlD8FJcQAwUR3vlY6lxGbSQmSbKOvhnGWMdCpv9GYFgOXVAzKBhKlGzE8lq7hsQlZH2LV4z1oOQQQ3NDnXozMFQZrCPvAE4a4ugNE5muqtPHqTln9Smg+4DbtjkR6sS41CTxeB9reVav4MU6GwA== Received: from MW2NAM10FT034.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::4b) by MW2NAM10HT231.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::461) 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 20:41:01 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e87::46) by MW2NAM10FT034.mail.protection.outlook.com (2a01:111:e400:7e87::231) 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 20:41:01 +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 20:41:01 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] [Vote] Adding return types to internal methods Thread-Index: AQHXN0sQDOXF4BnTpkyjI+fKo2GPt6rAKyIAgAO81wKAACPdAIAACfuN Date: Sat, 24 Apr 2021 20:41:01 +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:E8A6E657B6841C607CB52846BC88B5B1FBCCFB80115D0C6316266574B881F9DE;UpperCasedChecksum:52D25E5DB753DDE67331110FFF519A0E88E806B2CA63523E725D6F35B65982DF;SizeAsReceived:7304;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [WsPJuN2OrqRmr+8kgZgDYlralNvkr/t+5RRIQlNDnukIbxuU9zFJSOQ8WKMXc9Vk] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 4b7cd5ce-afbf-46e7-4693-08d9076145e0 x-ms-traffictypediagnostic: MW2NAM10HT231: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: GPUZIkpmgiRkpj87ClrOEn2jFNtLDh8B5EEyEEb5vT9lHOvRSQRrF4xytgkcXwpjsf+sVrRpV86VAttLv9+5aEO7GP4oDLTZeqamitUmOuVDthgTeG8mcugGZQxkpA9MpSGonph8vvJrF70C6chQ4S05gSc0cM9KQcKhRPSOLH5iiscFRWb+X+d1mEppLYRkPRZ1YQgp2/mcufMJZ0bhtZ8zzA29Gnw8a9MeSz4X5yX3ZPCWMJO7HECmCcgzPvdP6a+YJkKoT4WHZTxONP1op+9egHEl1tTiNOjvx4RAuCKc+AjfoMvh4XbgmQGf7PgLAMUNct+nCiP/v0xjC4g9ZNnktVM8IPP4DDsiG4PtA21ItxatI4zTvbQGKqhaakuBBe51GI3EIX6bEzGWjdzOzXMK96YS5v8Yk3J2YncUOD1oo5l47A78E7fBwzVu4sqo x-ms-exchange-antispam-messagedata: K4VlfANAp/hOmdZHSGlg8qvd8lc42FHsWYNl4nj8+POQMCmR+zgEikNRMWXT6z04QDlLFqTtzrouTCxLwImPM+iVgjBB6Ee+NLbLlWjrVye29iEuhijlou9mcNrZYOXUIjqE+QhupKufzhUmEA8DfJRTt7CP17oTm1yl7g8ZmxLJ62yDyRm8rdOmYbJR5g849jVSFBJRSH3qx4nW0kZMVQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT034.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 4b7cd5ce-afbf-46e7-4693-08d9076145e0 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Apr 2021 20:41:01.4464 (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: MW2NAM10HT231 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 type= s of=0A= > > those methods, I don't see a reason why downstream consumers would brea= k=0A= > > (stubbing tools, code generators, type checkers, dependency solvers, et= c.)=0A= > =0A= > If the published library/application had to support older versions (e.g. = php 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`/`neve= r`, 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 absol= utely needed.=0A= > =0A= > From experience, code generated with tooling while running on newer PHP v= ersions is already incompatible with older PHP versions: you re-generate th= e code when changing any of the dependencies anyway (think "no ABI compatib= ility").=0A= > =0A= > This is at least true for all codegen tools I worked/contributed to/used = on so far.=0A= =0A= Mocking libraries and static analyzers that don't result in published code = were my largest concern, generated code that gets published was a smaller o= ne.=0A= =0A= Changing getReturnType would significantly increase the scope of that incom= patibility earlier on for users that don't install multiple php versions=0A= (users/maintainers may default to whatever is provided by their package man= ager for convenience)=0A= =0A= I'd rather have a larger time window with deprecations to change those and = have any potentially breaking changes =0A= (from the perspective of users of older versions of code generation tools, = test libraries, static analyzers)=0A= in 9.0 instead of 8.1, to put the (small) BC breaks in major releases where= possible.=0A= =0A= The introduction of many `mixed` tentative types which makes sense from a t= ype system perspective,=0A= but with your alternate proposal for changing getReturnType(), =0A= but would result in code generating tools generating a lot of `: mixed` ret= urn types (requiring php 8.0+ runtime) in various interfaces and classes = =0A= which would be incompatible with a missing return type override due to http= s://wiki.php.net/rfc/mixed_type_v2#explicit_returns=0A= =0A= > We're mostly breaking BC (new methods on reflection symbols, requiring sp= ecial treatment) for stuff that is really an edge case that is only affecti= ng tooling that would really work just fine even if the reflection API star= ted to report the real return types now (no API change whatsoever).=0A= > =0A= > What's the plan for PHP 9 about these methods? Deprecation/removal? Or ar= e we adding something that we'll have to drag on forever?=0A= =0A= The RFC proposal https://wiki.php.net/rfc/internal_method_return_types stat= ed those plans.=0A= =0A= Unless new information comes up in the case of specific methods such as bre= aking commonly used frameworks,=0A= in almost all cases, I'd assume tentative types in php 8.x would become rea= l types in the next major version (php 9.0).=0A= =0A= > Non-final internal method return types - when possible - are declared ten= tatively in PHP 8.1,=0A= > **and they will become enforced in PHP 9.0.** It means that in PHP 8.x ve= rsions,=0A= > a =93deprecated=94 notice is raised during inheritance checks when an int= ernal method =0A= > is overridden in a way that the return types are incompatible, =0A= > **and PHP 9.0 will make these a fatal error.** A few examples:=0A= =0A= Tentative return types would also be used by PECLs, so the getTentativeRetu= rnType would continue to be used forever.=0A= (I'd expect PECLs would generally add tentative types in `n.x.y` and change= the real type in `(n+1).0.0`)=0A= =0A= The alternate design you've proposed of changing getReturnType seems to hav= e issues=0A= - For user-defined types (if we allow an annotation mentioning a tentative = return type exists without indicating the type),=0A= it'd be possible for hasTenativeReturnType to be true but getReturnType t= o be null, which is the opposite of internal classes=0A= - As I'd mentioned before, if return type functionality gets extended to al= so work on functions that already have return types (user-defined and/or in= ternal),=0A= in which case php would need to add `ReflectionFunctionAbstract->getRealR= eturnType`, but I'd rather keep the current semantics of `getReturnType`.= =0A= =0A= I personally expect your alternate proposal to be more controversial due to= the larger potential bc break and barriers to upgrading in a minor release= rather than a major release, but may be mistaken.=0A= =0A= Thanks,=0A= - Tyson=0A=