Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118063 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 58069 invoked from network); 22 Jun 2022 17:42:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jun 2022 17:42:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 61CCE180505 for ; Wed, 22 Jun 2022 12:31:40 -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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 22 Jun 2022 12:31:40 -0700 (PDT) Received: by mail-ed1-f51.google.com with SMTP id o9so16094522edt.12 for ; Wed, 22 Jun 2022 12:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Y2OOqk5CRAEFq+rw4xkhIvrtgbx6rEJlkhNevydkIbw=; b=PMqiZzqZAV2nBuy03gJ0oZX5Re1IhvH8zdyP1s0c7qE7aGRF6xhNZr2/j3RvufC0GK iRNOdoxUopHxUxhQ4HbwiFO4zI5G0797sjjHagdbumuMFF4jKApwO76m7diexeFMNeiH UMuiN5QzhNUIxxUG9L1FxEYajZjgSn4OSPQ7JAKL1TofSwIyf+4VKtaqGe5XPI6zoOuN vg250+/qsjqslxYJKt2wUFgvTHiTb8V7TWU6Kqmmuj2i62WgVDWscoPrYHLI3wDmnUhw jwUm/YTWL5l6NEDy+65QlucKG5gMZKQ7Py7EXbK5kmIO3tP88Y1evYNJv6guGvAGY6gK gGVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Y2OOqk5CRAEFq+rw4xkhIvrtgbx6rEJlkhNevydkIbw=; b=TA+ve2kZJku0emrnjVIcPKO8enZwlvnAcYLDTyOrp2ZxIXM5Q3jm4p7FCHzF2pF4fX nfte59quCrAJPIKd972tD8RtrLHAEm1UVDQlTtNOw4AIIRscd3M6OhliLGijt2Auo3Gx E3QD2UiohqHMvzOBsdZQMp7/8/PY/KRvPgoJc+B3YlnjNM0tKu18q2uU5q986ooWhEVy gyW6G52LNA0H1kJuZIDcPHsk0yCx/GBPTA3amgmzbQhO64zsYQkL4QkwkAwsYDcCDU8/ obWFwDbestXuua2DYp1arIQp4b8s+VCcs9RL9t5gU/UrEV//Dgw797EpE5LuW90EynSx wntA== X-Gm-Message-State: AJIora+eyyFsMUKavrotm4iYaEWthZzgsqq9Pgo0w644maUOjsa+nUtK GbcMuoEtKm6f4L1C0rgd+52nDmSAW19f5Fja/F1g6jH9mLPZcA== X-Google-Smtp-Source: AGRyM1uOnTtEJSE97Is/Y2iTdSeRsBeVzExZPMq9bVpa6DSJ1iJecTmXwbxMqaq9ZUPYLm7hsaGBmp2pV63v1BjLfBA= X-Received: by 2002:a05:6402:11c7:b0:42e:c47a:ffdf with SMTP id j7-20020a05640211c700b0042ec47affdfmr5990626edw.113.1655926298678; Wed, 22 Jun 2022 12:31:38 -0700 (PDT) MIME-Version: 1.0 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> Date: Wed, 22 Jun 2022 22:31:22 +0300 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000ce9ba105e20e62a4" Subject: Re: [PHP-DEV] [RFC] [Under Discussion] Auto-implement Stringable for string backed enums From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000ce9ba105e20e62a4 Content-Type: text/plain; charset="UTF-8" On Wed, Jun 22, 2022 at 8:27 PM Larry Garfield wrote: > > So I am firmly against making it easier to (mis)use enums in a situation > where constants are already the superior solution by every metric. The > only argument I see is making case 1, transitioning from a string to an > enum for a genuinely limited-case, easier. But in that case, the > transition is going to have to happen eventually anyway, and that means the > type is going to change at some point, and the same BC issue will appear, > just at a different time. Unless the intent is to then never change the > type and keep the function incorrectly typed (from the POV that it's > logically an enum, even though string typed was the best/correct type for > years) forever, in which case... use a set of constants. > > Hi! I'm with you on what you mentioned here. But also, I think the need I understood arises from another case that is neither 1 or 2. When you have two domains the value might need to be represented as a backed enum in one side and as a string in the other. As far as I understood, this is the case, with applications that are in one domain wants to have a proper enum for let's say the app roles as the possible roles are just a limited set. That application is using another library to configure the ACL using those roles and this is another domain that does not have a limited value on the role representation, it's just a string. Naturally, you should just transform the enum instance to the string and that should be done using the value property. But this does not work for configurations done through attribute parameters. And I think this is the only problem we should fix and that's fixable by https://wiki.php.net/rfc/fetch_property_in_const_expressions What you mentioned about developers using enum in the wrong way is completely true and it's been a long effort for me in explaining this. I was hoping it would be diminished somehow by increased popularity of enums, now that they are supported by everyone. But the usages are also increasing. Regards, Alex --000000000000ce9ba105e20e62a4--