Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115622 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17149 invoked from network); 1 Aug 2021 18:45:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Aug 2021 18:45:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4B9411804B3 for ; Sun, 1 Aug 2021 12:13:45 -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 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-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 1 Aug 2021 12:13:44 -0700 (PDT) Received: by mail-vs1-f48.google.com with SMTP id ba4so5486453vsb.5 for ; Sun, 01 Aug 2021 12:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=viTTgyxQEEWt1lGcMQA3SF3xEnZOvrZhfBF4P7kOUq8=; b=iYfQTaO7OdFsFSh2K+AIk7oA2pj2NjYD9cT/l0iTim6o3RFjejU8VcNMavZGM4abx0 ho5XUhpIcxTQCrW199eIr3u49lOhGZ0zUrnFYCShO4vS1DKIK1nV12fP6UI/ZHuBbvop 3ouM15zkVUwz+mESgcTEXqBnPxsJTVSyYoTuKaTucQnXjiiEiDUNUvsFM6dE4ZuU/ZpV Z2RFNezyEmue09NJL6C85EqRDeo2XkR8aD7DnAcEzqKlV5EWTjMPZixjle05y4RfP1vI 62YPdrJJaBlKgaYme9X/MOd7oIBcZkc1dlQ0e58gpja6RWlUW6vNT5vs4CcHgUSeMm+5 8KGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=viTTgyxQEEWt1lGcMQA3SF3xEnZOvrZhfBF4P7kOUq8=; b=CCwokvSiECXRObHZ38i67FHwD/4eOu/MpKM4yiaYfK3JuAWFVtzPKdcFy3mzJHA9R2 9GPfuNnJqVuYAWO9agdVmQXubuT54x08jotLCUoAVvuJLcFvFLFEGkXxTsTGbJ3uQASi DPBxxF081UPDr+td+osPqhblG71OepQL+8hbTMg8tE+ylRuIGkayMFyqT7aD6zkHEv2a IkIT8EsKphAX/casdSRj3O1wRakWqQQGRb+vzM4s5r1EmiKm7P8ALgR6VmTM80TX/uyV Z6WQTgkB8rODYw5FfnIa6pKR+qMg1QJwVEUyWKguPm0dyIKOyGfo0vw3RsqlxwEL4w9M 0YSw== X-Gm-Message-State: AOAM533HqXPMta0XfFCsIaScgPrf4BhRQROgmQitXazl00BFv/Qbo4tj gd0CRq5eznGppDFKu83G0RFLbzngdb7AbK9Cg+0= X-Google-Smtp-Source: ABdhPJypBSnSn+vYSKEThV3ORSwV9MeYXPEJfffPIF79PQcNhPo8eyCu0gqCfYZZf7z52D3dXETz9di16Bv4pRpbBx4= X-Received: by 2002:a67:22c5:: with SMTP id i188mr7777215vsi.33.1627845223142; Sun, 01 Aug 2021 12:13:43 -0700 (PDT) MIME-Version: 1.0 References: <22EF92EC-C5A3-498E-9EFD-DE2B5B204BB7@gmail.com> <6e668a49-d69c-7b6d-f9c4-1d3fe2058d27@gmail.com> <7FAE3AE2-F8C1-4774-9B84-721DE8FF49D4@gmail.com> In-Reply-To: Date: Sun, 1 Aug 2021 22:13:28 +0300 Message-ID: To: Rowan Tommins Cc: Internals Content-Type: multipart/alternative; boundary="0000000000004659d505c88440a1" Subject: Re: [PHP-DEV] RFC: autoconst From: free.smilesrg@gmail.com (Serhii Smirnov) --0000000000004659d505c88440a1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you! Seems like Enum covers this case. =D0=B2=D1=81, 1 =D0=B0=D0=B2=D0=B3. 2021 =D0=B3., 21:58 Rowan Tommins : > On 01/08/2021 16:59, Serhii Smirnov wrote: > > class Features > > { > > const FEATURE_FLAG_WITH_SOME_LONG_NAME =3D > > 'feature_flag_with_some_long_name'; > > const FEATURE_SOME_ANOTHER_COOL_FEATURE =3D > > 'feature_some_another_cool_feature'; > > } > > > That looks like it falls into my first category: the actual value of the > constant doesn't matter, you just need to be able to compare against it > later. > > That makes it a perfect use case for PHP 8.1's new "enum" type, where > you'll be able to declare this: > > enum Feature > { > case FEATURE_FLAG_WITH_SOME_LONG_NAME; > case FEATURE_SOME_ANOTHER_COOL_FEATURE; > } > > You can then even define the "isEnabled" function so that it only > accepts Feature values, not strings (i.e. "public function > isEnabled(Feature $feature): bool { ... }" instead of "public function > isEnabled(string $feature): bool { ... }"). > > If you're not familiar with the new enums, the best documentation at the > moment is probably the RFC which proposed them: > https://wiki.php.net/rfc/enumerations > > I'm really looking forward to using them :) > > > Regards, > > -- > Rowan Tommins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --0000000000004659d505c88440a1--