Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116187 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51548 invoked from network); 2 Oct 2021 13:53:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Oct 2021 13:53:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A864C1804D8 for ; Sat, 2 Oct 2021 07:37:08 -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=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_HOTMAIL_RCVD2, 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-ASN: AS8075 40.80.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2094.outbound.protection.outlook.com [40.92.21.94]) (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, 2 Oct 2021 07:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NYlCG0cnwxwDsylJuSvvoxvthX16b3IXEs+w3JN1nbtJ2/8cfuCHljMD35dqH5Uj0CxBcXYqBPVutN2KOzTXxbVHJ6aN/PNtzCai67WEJkjFqbfDvhuDy+urVXLtFmmbj0VIh+paf3Vr/+4oSxJcK8Ohtfniwu/COr4Jys8kf9gvrxZC/pXp5//rmB4DImDYPGjdT6QtfegVTu147X6WiAGP+ftBFDeGpKNcE6RAir5k5NVr7AKfIQR3n/tZjH/wPiRllY4yN5niqk70FZkNGh/lhYjXJzKX0HPzWmFfXP2iwX8tSp4RBliS7B6ifMxINFN0yUbYExE4jI57Ww+H1Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cmkz8Y11yWK8l5mvhpwdpomtP3yNOPKUde25k2icE7Q=; b=KrJXJE5uiwYmd+nPtMZpL4uu7rwGQNsmlE/0T4BSWIUdhpLMIy4pmERbcEjNt7gTF94UPdsmdvhvjQgsqN4xrHaZrpOLI2/jkAarPXkwB9Cxa9/s23RH2vqWM++EyQuscww3WtD/jQYfEpI+e2YapT5ZNS0JeSlFD8LpRvnmVoEsHUNc0V/BuP4lX7O6cguIixkKYz4pH4DhWyxAbr2akXkQY/KnDCDTPri/GKGREJNbp5n+T6cpNU9VAb5u06EcD3BgUHzzuzXEHhr32JYxSpZwc7SsV+rdJXt8Mq3dyPcQ0lAgvbczF7Wxjr3eClHdgRNZ2MwcVH81yDlpFskdXQ== 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=cmkz8Y11yWK8l5mvhpwdpomtP3yNOPKUde25k2icE7Q=; b=ZbV6dxbh2zU0jkt3DC+LzB3rrul1G9Tx68/ZPDFGFNryTKRInCPzpDojqNf1TNUV3O5iVwP1HFsVLfVsQmWYcnjYY29eyxXF60UgsdEotolZweG+PSnl3lDPP3bcIWBJXXwRcRrmLVD8Yegxusp01hjBKrpbARpcG5cV6ibGzx3TcyoG0LbVjYBM9XWS2QAczqbDveQtuaIjjarD3NtXTSZmOkm6PZS1oVaFxTt//a6C2AMk/5CyO2vAWKFcZP1ozdkJhWxdE9SjjyI0CChaQbi0NVol6NIblOFmNo9hISDGjgsDt6uiMiBWfvnSmQrql1yWHn/pHY0j1Hg5gKzMjw== Received: from DM5PR17MB1481.namprd17.prod.outlook.com (2603:10b6:3:147::17) by DM6PR17MB3980.namprd17.prod.outlook.com (2603:10b6:5:25f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Sat, 2 Oct 2021 14:37:06 +0000 Received: from DM5PR17MB1481.namprd17.prod.outlook.com ([fe80::e832:bd41:4114:64d2]) by DM5PR17MB1481.namprd17.prod.outlook.com ([fe80::e832:bd41:4114:64d2%11]) with mapi id 15.20.4566.019; Sat, 2 Oct 2021 14:37:06 +0000 To: PHP internals Thread-Topic: [PHP-DEV] Unified ReflectionType methods Thread-Index: AQHXtx+jBsOAc8JukE+PEAax2w5CUau/xJUg Date: Sat, 2 Oct 2021 14:37:06 +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: suggested_attachment_session_id: b191bdf2-96e4-cf47-0a0f-bf0361a03d26 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [AajMc4ZXcBJ8jwH+IXmQVgmD3EMXVq3i] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5536856b-667c-4804-d32f-08d985b21bdb x-ms-traffictypediagnostic: DM6PR17MB3980: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0aziOb57m/10Eho1NNY4Oc87eEmoRpb6faynF8DtLoDr1LyU072EzewoWA5L3wWWu/PcLafLVZ6KlRiUK0t1XpCCPlYIVFSGS1pQUI7itsaxl/DzIHuPMARL2sK1QotLUirRLExKhb2c24eCuTi2KzXHmkloOTfBr7AxfdKi4iFZ1+HDQDV2edYUmttU6EV2zxCwNcp5SrkMyfqaJGHuT6IM8ICjpw/u9wFRpZSZTOduTrUnWxr9g8No/rVF1Wvfig7v+7mbz1DzfZyuj4pYHSNF3OXr7dqEEvI6qHB4GS8LS3NPuRCrPoBkrjkYqeHkgxzL0a84gGFE08msobag6OhobZqhlSwLDmKTxsRUQKfY/FR2xUebJkJuPCk7px3SUTAqX+7ctxP5kSvhJwaVUut1UsNECZaTafTC86UTwSTvRPUY9HGbDJzrxFOoy+0r x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: zLWEOGHUgQK2Ex4N2b/3PoPDIpbEgChiC67lj+Dt6Jj0JG5y5w5lyEOhanQKOVhCEtLnIRo2ypI7m1nDsLh8gF5JWwIabh3NyEjp1CjfmfDgd6KYY4L8hzPFD9N02MgXKP+NZ1fTK8WxJvWKTuMhcQ== 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-21df5.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM5PR17MB1481.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 5536856b-667c-4804-d32f-08d985b21bdb X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Oct 2021 14:37:06.6950 (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: DM6PR17MB3980 Subject: Re: [PHP-DEV] Unified ReflectionType methods From: tysonandre775@hotmail.com (tyson andre) Hi Andreas,=0A= =0A= > Hello list,=0A= > I would like to propose new methods for ReflectionType, that would=0A= > allow treating ReflectionNamedType and ReflectionUnionType in a=0A= > unified way.=0A= > This would eliminate the need for if (.. instanceof) in many use cases.= =0A= > =0A= > Some details can still be discussed, e.g. whether 'null' should be=0A= > included in builtin type names, whether there should be a canonical=0A= > ordering of type names, whether we should use class names as array=0A= > keys, etc.=0A= > ... =0A= > What do you think?=0A= =0A= Relatedly, I also had different ideas lately about new methods for Reflecti= onType, though of a different form.=0A= =0A= 1. To simplify code that would check `instanceof` for all current and futur= e types such as `never` and `mixed` and intersection types=0A= `ReflectionType->allowsValue(mixed $value, bool $strict =3D true): bool= `=0A= =0A= Maybe also `allowsClass(string $className, bool $strict =3D true): bool`= to avoid needing to instantiate values (weak casting allows Stringable->st= ring).=0A= 2. To simplify code generation, e.g. in mocking libraries for unit testing:= `ReflectionType->toFullyQualifiedString(): string` (e.g. `\A|\B`) (may nee= d to throw ReflectionType for types that can't be resolved, e.g. `parent` i= n reflection of traits, keep `static` as is)=0A= =0A= (The raw output of `__toString()` isn't prefixed with `\` (e.g. `A&B`) = and can't be used in namespaces=0A= =0A= The fact that both intersection and union types (and possibility of union t= ypes of full intersection types)=0A= make it hard for me to believe that getBuiltinTypes and getBuiltinClasses w= ould be used correctly when used.=0A= =0A= Thanks,=0A= Tyson=