Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:117022
Return-Path: <tysonandre775@hotmail.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 7277 invoked from network); 13 Feb 2022 14:33:25 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 13 Feb 2022 14:33:25 -0000
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 203C01804D0
	for <internals@lists.php.net>; Sun, 13 Feb 2022 07:50:40 -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.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: <tysonandre775@hotmail.com>
Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2072.outbound.protection.outlook.com [40.92.40.72])
	(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 <internals@lists.php.net>; Sun, 13 Feb 2022 07:50:39 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=dUZhI7cwilm69eAT7ep9v9NjjtMdG+S4dL0p+iCRcUYb/W8DL2gTTyTRkXv4y5RAse/87Q4azlSjAP/CKMkjrEwodbxAMDsowv2cyAjlhQzf72TbDExNF4IgjIlavLt0sHgclexkvEA2/jhp7iqrYOFPzqme3e72uQiiVV3786SgbX4UNjNEmXoeAKI3dVG3Db4mkZrzYNuZ2fd3S0CBOhAFJ4F5dQNFqKGBQQTAk+9SsRHKQtDUbc2D4IEU1xQ+CgCZYY9eKWUHCO+fliIZ/kVEBjzevbKCZmro0ikiSZ47FhIom8/dXekVhARTDLzWsMoH0FG8qe/rPBgVFSBO6w==
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=EquMU0NpLQI4TniP5rFpORCdWTXS5AoSx9/ScBnjUy4=;
 b=fRlhNhxIFb7tMDNQzhlOjICdoclxXBirGB6JqPCw9TcNOMyvO8DxKVfSwqirFJxaQDWA5DRaONQcNgRKJDBx+5MFp4DE4bzOo9DOQGqeKu5vcnw6pOhXkZApZiit5mEHhz0ucLXkWm59bvXY9ZA0QizZkg379VdRdahHbK/W3wpOOKaSyYIJFVQmPoPPh5T8orMdpCB6QMT7YAq1AbSqw3noRqSNEWAaVaukkuoIMh1xOglMWKDUX0uNAs5fZNyB3DOA/gTfON2Ym9z+nA8UGhwTSn2gTHtO1TTR9JWeGPJhhvYkaHpha6IsTuUCFeSgRMu4tOvUsF8xe1EwwfEP2Q==
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=EquMU0NpLQI4TniP5rFpORCdWTXS5AoSx9/ScBnjUy4=;
 b=ifiGd3RUr1siS5YoKEJ36+Bb2qp2SZNQ+bKEO449SgjAP5etV8wmGU4fKADQxCkPzsexQIt5wDwBzGE0Jp4EJmj51vowllV6gjsAwwFAr1QigGSXo9GKhQrsshPJ6gd80PDvd5Uay9+84ZguqW5Wk1s+ZGBBlkgjdo8Nu8QiLglR4meHnR3K/xj39yssJhq7KLy4ayyLQmsz/XtNm/zrhsxLdAQGO37SkT2ABdu/qq63ZE7Lq3UjARGa6gIfJBHYF03ZnOCI1KTWdcas5tZnxzVJWf5GeDe3SOTE0hWUwJo5ZHKNxHiRGLDx8veehIDHG4ywGk50/1ijc1bXK1zmVw==
Received: from DM6PR14MB4155.namprd14.prod.outlook.com (2603:10b6:5:21e::11)
 by BY5PR14MB3815.namprd14.prod.outlook.com (2603:10b6:a03:1df::21) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Sun, 13 Feb
 2022 15:50:37 +0000
Received: from DM6PR14MB4155.namprd14.prod.outlook.com
 ([fe80::1ddb:6eeb:a96d:9846]) by DM6PR14MB4155.namprd14.prod.outlook.com
 ([fe80::1ddb:6eeb:a96d:9846%3]) with mapi id 15.20.4951.019; Sun, 13 Feb 2022
 15:50:37 +0000
To: "internals@lists.php.net" <internals@lists.php.net>
Thread-Topic: Adding `class UnsupportedOperationException extends
 RuntimeException` to php?
Thread-Index: AQHYIOpeOla0owmmM0OvsT6zmE2Z4Q==
Date: Sun, 13 Feb 2022 15:50:37 +0000
Message-ID:
 <DM6PR14MB41557A1D56484251B5F9AF37F9329@DM6PR14MB4155.namprd14.prod.outlook.com>
Accept-Language: en-CA, en-US
Content-Language: en-CA
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
suggested_attachment_session_id: 8f5efefb-a907-eace-05cd-4b8b62f878b6
x-tmn:
 [OdIp3CFEuea+qFd1Ton/+8Sfo63C4K/4vuPFFWmhuaCqN0pQV0tR5QvFgE8aJoV21z5No7V2+lc=]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 07b4ea01-056a-4de5-0f93-08d9ef089405
x-ms-traffictypediagnostic: BY5PR14MB3815:EE_
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info:
 0UPQgInYJstvQGur1YadTC8NcJqqznNGZl+6EFDkjLAe9HnU9qyOMX7KRV1tp1JcWFastjopWLJ8iLOCpOeO1g6Ek5Q2m6mdw0fILNC8YD3tY8PqRYeW2QTS+vOoVSOSx8FtwrpGz+zXCT7g+zA1mCnAMM8vviBjwJlpKnPVSZ+YIgQ79XXs0x3VAcdof0h1UDV7Ta+JKZTe4mgmp5Go6DTxZP0BJdxEp1SP0tPHt60F0ExzmO/P70i/asgHdI/9GVNpGlrsOUrWzVefFl7/kZI3Z0yp9pX7fttDvYL8GJ+D0/qDhevtaleIi2iFfi34U6wRld/lzM6NSCedE53GQHxwEwDQBDwlisll5AF8pxOjBmOEIt8y0rjxgf+ZbGt/7g2zN2AihUjU1dF56w+hqPpHkS3E2582osF/og/FrjXTLmZGttrWLeG1F17jX/drH49eeFmlm09iAK06cJTxCkaroowlm31MX58jsgE2fPpvCAok0X4Kj1WiYSkFF2YZDJBE6bvbGGoQTA2lh1DdoXqWWGzpRmJWj7ICC1Ve37lDJlOHFX+81s8nWueE1M7kbBIsr8f0vxXWpyXnBOQ4qAho9U93Z2uVS9XVXbixmtMgkyMT4TB5Riv6K5Hf6Ns2jeJwHCh+ync88giUUR1Kio7BfcWsJbwgC9DmoVlba1Q=
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?iso-8859-1?Q?8R5kr7QlZevRwpk8z5XdOZITIyO46dDTcqDvRHBkkLJbwcKT5h4ETYFLut?=
 =?iso-8859-1?Q?pbY3OnJktchK+ic19i7WEVWKxngXlV0bkfcuMkk8Jrz9elgGAIhSvj8dPY?=
 =?iso-8859-1?Q?88AQ/nFTYFHqZ3uwWoWOGR1YyGjSwJfwhEzg8i8h5uTFmzrwsR+jsn9San?=
 =?iso-8859-1?Q?TGd5uTtzjNjFZPvVh2W2NxwuOGLRUfVHFfFGBOAIlaDE0KztHNrBI+kYPV?=
 =?i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=
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-cd57b.templateTenant
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM6PR14MB4155.namprd14.prod.outlook.com
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: 07b4ea01-056a-4de5-0f93-08d9ef089405
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2022 15:50:37.1147
 (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: BY5PR14MB3815
Subject: Adding `class UnsupportedOperationException extends RuntimeException`
 to php?
From: tysonandre775@hotmail.com (tyson andre)

Hi internals,=0A=
=0A=
Currently, there doesn't seem to be an exact fit for indicating that a meth=
od isn't supported on an object by design (and will throw unconditionally).=
=0A=
(For example, when implementing an interface or overriding a base class, e.=
g. an Immutable datastructure not implementing offsetSet/offsetUnset,=0A=
an object that does not support serialization and overrides __serialize/__u=
nserialize to forbid it, etc.)=0A=
=0A=
- BadMethodCallException - Exception thrown if a callback refers to an unde=
fined method or if some arguments are missing.=0A=
- DomainException/RangeException - Seemingly refer to argument values=0A=
- LogicException - "Exception that represents error in the program logic. T=
his kind of exception should lead directly to a fix in your code."=0A=
  I don't believe it's quite that, because code designed for the interface =
implementing the method (e.g. ArrayAccess) might have correct logic,=0A=
  it's the choice of implementation/subclass at runtime that caused the exc=
eption.=0A=
- RuntimeException and its subclasses are also used for unpredictable error=
s such as missing files, network/db errors, etc,=0A=
  making the meaning of `try { ... } catch (RuntimeException $e) {}` less c=
lear.=0A=
- BadMethodCallException - Exception thrown if a callback refers to an unde=
fined method or if some arguments are missing.'=0A=
  seems misleading as well since the method is defined and has its argument=
s, and existing uses in CachingIterator/Phar are checking the object's prop=
erties or arguments.=0A=
  (Uncaught BadMethodCallException: CachingIterator does not fetch string v=
alue (see CachingIterator::__construct) in %s:%d)=0A=
=0A=
RuntimeException (or a userland subclass) is the most common exception type=
 I see used for this purpose,=0A=
but RuntimeException is already used for many other things and has many sub=
classes.=0A=
https://www.php.net/manual/en/spl.exceptions.php#spl.exceptions.tree https:=
//www.php.net/manual/en/class.exception.php=0A=
(RuntimeException and subclasses are also used for unpredictable errors suc=
h as missing files, network/db errors, some types of errors in destructors,=
 etc,=0A=
making writing `try { ... } catch (RuntimeException $e) {}` to catch this a=
lso catch other issues that should instead be rethrown.)=0A=
=0A=
It would be useful to provide this instead of having extensions or userland=
 code throw RuntimeException or=0A=
implement their own exceptions https://www.php.net/manual/en/class.solrille=
galoperationexception=0A=
=0A=
IDEs/type checkers would also have more information to indicate that a meth=
od call is probably invalid in a use=0A=
case and it would allow userland code to be have more specific api document=
ation/type info than `@throws RuntimeException`=0A=
(rather than deliberately invoking a shared helper method to throw exceptio=
ns).=0A=
- Type checkers already check this - e.g. https://psalm.dev/docs/running_ps=
alm/configuration/#ignoreexceptions https://github.com/phan/phan/wiki/Issue=
-Types-Caught-by-Phan#phanthrowcommentintostring=0A=
=0A=
Thoughts on adding UnsupportedOperationException to the spl?=0A=
=0A=
Thanks,=0A=
Tyson=