Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118060 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49328 invoked from network); 22 Jun 2022 16:03:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jun 2022 16:03:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 947E51804D4 for ; Wed, 22 Jun 2022 10:52:49 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.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 ; Wed, 22 Jun 2022 10:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1655920367; bh=zNAYL10WR6fd1qgXDDUnP+NH3u7Oyt9cCQ1JJf3AVKk=; h=Date:Subject:To:References:From:In-Reply-To:From; b=aOfgPkQnYHszlSdf/KgXCY1cSA0xsg0BkVHd9e4rudl+kWPSpv+amkxuWuGjtCQj8 ztvOnBhG14USgW0YIM7708Fdubnv1M8s1/Bklp/2I1MgnSEao4V3TPSy8u96qldsZE WnJK+MzGiB5XeBgOfOx+nkh4tg1VsdLMrUxYpe5Cah1GCHO+XyjaQE3GQn8Y/QORSB ri1Vmi1c1LnOE4Z/ob84JSdwnjcPloF7KjiF8RNnJ80Wh/8/jltNBwvKVCs5dK14Sm Gt3qcNjUwiEVr+A0I9rWxtkuvIGXctTr6fOCnPOA98y/+lfGiVuGChkUuq0r8BN9h0 SwxxjbhLoR8Xw== Message-ID: <1cc14578-77eb-6cdc-95b3-1362d94765b8@bastelstu.be> Date: Wed, 22 Jun 2022 19:52:46 +0200 MIME-Version: 1.0 Content-Language: en-US To: Larry Garfield , php internals References: <9C11261B-B9D0-4342-81EB-60276B3036E5@php.net> <2cee17c0-7b77-4709-94b9-598a4c3d1f49@www.fastmail.com> In-Reply-To: <2cee17c0-7b77-4709-94b9-598a4c3d1f49@www.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] [Under Discussion] Auto-implement Stringable for string backed enums From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi On 6/22/22 19:26, Larry Garfield wrote: > In case 1, I'd argue that the function should be switching to an Enum long term *and dropping the string*. For that, a union type is the optimal solution. Does that have BC implications for sub-classes? Well, yes, but so does any type improvement. This is a known problem space, with known solutions and migration strategies. It's conceptually no different from migrating from "this takes a string" to "this takes an array of strings": Widen the type, have transitional code, retighten the type. The time frame for that could be weeks, months, or years depending on the situation, but it's not a novel concept. Exactly this. It might be painful for existing code, but I expect any newly written and any updated code to handle enums "natively" and so this is something that will solve itself over time. On the other hand once the enum type safety is watered up by allowing implicit string conversions, there is no easy way to revert this. Best regards Tim Düsterhu