Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112756 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 88730 invoked from network); 5 Jan 2021 09:37:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jan 2021 09:37:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 91C321804E2 for ; Tue, 5 Jan 2021 01:13:32 -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=-0.7 required=5.0 tests=BAYES_05,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-Virus: No X-Envelope-From: Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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 ; Tue, 5 Jan 2021 01:13:32 -0800 (PST) Received: by mail-io1-f44.google.com with SMTP id q137so27529348iod.9 for ; Tue, 05 Jan 2021 01:13:32 -0800 (PST) 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; bh=cZrn3F5ySXynfxXbsGENdIeO3c2NoM1gbPGYV7ofGHQ=; b=I7lhxBbRxRh2ASU9/p+AbEgIRjMZLozQ75ns46U3pCfJSnI1lpvQnlKt0nd3EPui02 RZFdqJJ5S35kWx5ohAObTMCr34NqN6Bu0n7WcZTQ3micZGEuvtrpZw/+DLjS96a7wa6n zl8wbERshFutx4Gn0u4yXheW9pJGqMrp4+QKqNP/XzTdcLHCWT2kNeCdYCK/WPfKudxV iJ3f3I9Fkyn1AHZ3SVKXmtJw3yfs99YD46T1CUzbVa0LJ37xe05/ZLUu3CKBz37FPcWU r0CnmH/mvZMMsFc8dpkQV4VALHd+mnJbWBzLicitBTFpd81JvBrs/Y7f7D4gn1bgccSM yjdA== 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; bh=cZrn3F5ySXynfxXbsGENdIeO3c2NoM1gbPGYV7ofGHQ=; b=EzxansJ79Rk6adRzm5wJKvZWyDOEpbk+b990H4KiOjT4yh1wguSYcvQ69w3B4SulTM 3pd1UWLB44/6xdlz23PbgUU0PTBF4rMb+2IwoIjQPApTyEBq1H9spXBj3Tyo1As6DWHP SZEM4ewWdFJqvOWE+e0TEH26yafwKEoJaixE+GYYIum76tBL/+aOzrqkoCdBFMTz2MBY vqO2gWy3T1ubkl86OgEB5LqVXudMdOq8Z+8KoS6ikXdN3nJmw0atxjfH2CGHbU4Oq426 LncnQBqNa272p3islhGxJzxW/dXq6MCdaoWqZUeYsE9reKhaED49Ip0mhuhrL+BNkK7V OhRQ== X-Gm-Message-State: AOAM532M7MvWT8gA+wNx1yc67NEBn1l+YTggwoL/EmYZuihx/0w/J0ju s/keGuPu0fEgxmbYnxetwYJkz0vU1XU= X-Google-Smtp-Source: ABdhPJwR2wxqa321AVNX9Gm+YE9vhbSVUUnqL1gFv9Q4SAVWHKQpfwkZPN6hPMqtYy4xXQ1GyM67xQ== X-Received: by 2002:a5d:8d94:: with SMTP id b20mr40731763ioj.200.1609838008059; Tue, 05 Jan 2021 01:13:28 -0800 (PST) Received: from mail-io1-f41.google.com (mail-io1-f41.google.com. [209.85.166.41]) by smtp.gmail.com with ESMTPSA id l78sm44043163ild.30.2021.01.05.01.13.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Jan 2021 01:13:27 -0800 (PST) Received: by mail-io1-f41.google.com with SMTP id y5so27590488iow.5 for ; Tue, 05 Jan 2021 01:13:26 -0800 (PST) X-Received: by 2002:a05:6602:228c:: with SMTP id d12mr64502778iod.67.1609838006784; Tue, 05 Jan 2021 01:13:26 -0800 (PST) MIME-Version: 1.0 References: <8aa05350-05fc-df9d-e5d6-fa0f4feb57ba@alec.pl> <4eec7448-f7ab-9955-8c2d-68cd4f822535@gmail.com> <7d8ce2a2-8d85-4312-af22-da643faa3a7f@www.fastmail.com> <1BC8BF20-B961-4360-855B-5BB95338BB8A@newclarity.net> <30e219c4-bfcb-026f-630e-bda8f21b3787@fischer.name> <642fa510-3dd2-da98-e0cd-3aa83ee2dd90@processus.org> In-Reply-To: <642fa510-3dd2-da98-e0cd-3aa83ee2dd90@processus.org> Date: Tue, 5 Jan 2021 09:12:51 +0000 X-Gmail-Original-Message-ID: Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000008a704205b8239e84" Subject: Re: [PHP-DEV] [RFC] Enumerations, Round 2 From: phpmailinglists@gmail.com (Peter Bowyer) --0000000000008a704205b8239e84 Content-Type: text/plain; charset="UTF-8" On Mon, 4 Jan 2021 at 15:21, Pierre R. wrote: > I do not agree with having values per default, this is error prone in > most of my use cases. > > In most case where I need enums, I often need to replicate those in > database too, or in message broker serialized messages: in this context, > whenever I need to fix a typo in a enum case name, for example, if I use > default values, I would have errors with my existing database records or > live messages. > > I prefer to keep an explicit switch/match to hydrate values from > database or elsewhere, and use a value-less enum on the PHP side. Case > names are the only semantically important value for the developer, and > your code should not care about having a string value. In most cases > only exchanges with the outside world in an heterogeneous environment > (having a database makes it heterogeneous) care about having string > values. In this case, I highly prefer having explicitely written > (de)hydration code than automatic magic values happening over the place. > I agree. Peter --0000000000008a704205b8239e84--