Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127233 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 06B0B1A00BC for ; Mon, 28 Apr 2025 21:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745875530; bh=fcvbGqaUIMdXdRS/U9yrEH/UOwNy02z3N1qqjRuUB1o=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Ul8bQJUiI6dA0185sGOjfSIa/4Ya0n2d+MrdrV/MuXWbaHYmyWyX4gvGZkfcbeQW5 AQpcv3o4ecd9TPCQt6mAYJFbDtLCuhLUCB024a5gFS03U07pXaAENnDw4DbPeya178 QHyxZiX4VBWNx4l1dP+7ytzvtzYFst0N9TCgue1BUyncDUmIkWH9hh7nQQQci6Vtb3 MAGuOHK3mlkTQ8ZA9zJWmIHvC4HOvIfQlpFiaVOPEFy11AxNtHgRrv8PQ5Y6jcx8hR LljxYHtWkk4q9KW2VfnrjBl+MfjcX6UXd1DCQp7qc7zPRqar7cbE1tDyr8oQm+m06F 9F7cYEPfCgxKw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 966FB1805A4 for ; Mon, 28 Apr 2025 21:25:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 28 Apr 2025 21:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1745875665; bh=mE6/21fVAuYNpFaG9QYDIn3YXQQXK9TjPI1EQDtSU9c=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=PmrLiwjLWrTP+/DnaZh7HM4EelowBSr+b4R/U9O3pFZha7TKJGEWnd3FST0itinFL B8Pt753jetfJdyP6R09MvSTdVKhKx6PmlKz/FC/ebzQqrViTlJsFs51UKAuZFts3mj sINOAw9TZPO6s2j4PkSutyzUsWN+YO8HUciAfKa0Hl33LoIMwOrUR6srzXLHC5LKFK wZVigXdiJxxDIjjoN4ykCd4Bja8iJMVqg9pQNrRREBgB0OeozTvFHDuxaXLiszD+DK JCUp34cXyRdBDxWzd06htvLl0po0a8xSpPiF2jqXoN64+g0o1OEJ27mha91K+SunWe Q7LggY9FST1CQ== Message-ID: <39af290b-358a-45f4-9d2d-c76dd4e08125@bastelstu.be> Date: Mon, 28 Apr 2025 23:27:44 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions To: Larry Garfield , php internals References: <8c35314a-e307-4018-8685-39d7a7923cbe@bastelstu.be> <4de85c52-9c04-4e66-9654-af1a377015e1@app.fastmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 4/28/25 23:09, Larry Garfield wrote: >>> * Would allowing an extension-tagging interface instead of a base class be an option? It still allows for catching "anything thrown by this extension", which I presume is the goal. If not, why? >> >> See the “Choice of Base Exception” section in >> https://github.com/php/php-src/pull/9220. > > That seems to be about not having a common interface for both the Error and the Exception, which makes sense. I'm talking about `interface ExampleException {}` and `interface ExampleError {}`, instead of `class ExampleException extends Exception {}`, etc. Besides not following the de facto standard (which is what this proposal is trying to codify), I'm also not sure what benefit an interface would have over a base exception for the problem we're trying to solve here? So I can return the “why (interface)?”. It would just make it tempting to extend some SPL exception :-) I see the value of using interfaces for exceptions when the functionality implements an interface that defines specific types of exception (e.g. PSR-18), but this is (literally) orthogonal to base exceptions that group exceptions by “library” [1]. Best regards Tim Düsterhus [1] Writing down these words, it would probably made sense for ext/random to define a Random\EngineFailureExceptionInterface and specifying that Random\Engine::generate() must throw that one, rather than directly throwing the Random\RandomException base exception - especially for userland engines. But on the other hand an engine failure is not really programmatically recoverable anyways, so that's probably why I used the "simplification" back when I designed the hierarchy.