Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114506 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9560 invoked from network); 17 May 2021 15:49:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 May 2021 15:49:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F1D5A1804CC for ; Mon, 17 May 2021 08:58:24 -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-Virus: No X-Envelope-From: Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) (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 ; Mon, 17 May 2021 08:58:24 -0700 (PDT) Received: by mail-il1-f180.google.com with SMTP id z1so6571468ils.0 for ; Mon, 17 May 2021 08:58:24 -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=Kt16ZKIKjcC0yIQMjc1Cjbc1ThkaGdzlhDsnJ8nIgVk=; b=WiQUpNSePVuIO/kbcUUdWd6C+9a2IEH4aZczsBy7pO2qhOQpkQTcNx+fa2XOkT6nQ+ qWdSVKVi8mvLcqdJGYazyQPjhS0DlujuBhiEf9fqLiJ0+eXIC4sRicsQ9tgzt9DT3yVA MjGMh/CbBZoFnviAn9Z4CQFCnkVTxx99H1USfXK7zg1bPW0ye+PIjm0Fpi6gePm6QU7S dL82dpoW81P9q/BOxLdcEkFeZciB9Y1MIaSMiMyrMAETVi7oG4jBdYozJzKhHWeRSfXe HkA7BwhB9HHgVUT+Qhq4eyHZKRCuzn37c+feKY7H/i1i/wcni1MpohWmSNFu2Pfi+eLB 27Gg== 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=Kt16ZKIKjcC0yIQMjc1Cjbc1ThkaGdzlhDsnJ8nIgVk=; b=XPg2x329IEquRYl9FgcenA4zkPf+0BBfmYBr3TjMyScWP6t6v175BOdenCVfEBahFP RAO5MNr4Xn9YO04K42vhhKlaN/KgrxcMavGVE2j8+wOcZWm991hKaKMkWk8TuXhA4Bvu Y8b4NyIYHQukzoLv/N9cng5jUSYP5i0pJA8oH1rbsinbIFFrfFquBuKvUJMdBlUgFiz9 Kfc3OlE1Im2099HME46u/UAglH/jTD5teZmtfL3NXW6PJ1PX2MmTbxztITllTZAU2lMP 9wr/SnG4zSwxrc2gqYjRsdppEvVMkIo2pQ2e/M/8pp9nrdcsovcAVje+iQegRKDuBzr5 0Y3Q== X-Gm-Message-State: AOAM530Zftw5dKdrfpw7KkmwZLxFoPXcvJn1xUMNc6u0w7+oZ0Ya4lvP fnCjbUaGdE5yGQsoMSkyyDANcD47lqVpOxgnXp/1JKf/IZDMcw== X-Google-Smtp-Source: ABdhPJynAr24YyEy+hvS2CtDGIw8Z/T4n5ubuXLZEZbUddHr5DNbfA5OpftqY9UF4HRGBUhMkj01UoBg70xib546VdU= X-Received: by 2002:a92:6804:: with SMTP id d4mr328176ilc.5.1621267103865; Mon, 17 May 2021 08:58:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 17 May 2021 17:58:10 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000cfdf6205c288a968" Subject: Re: [PHP-DEV] [RFC]: Allow static properties in enums From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --000000000000cfdf6205c288a968 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable pon., 17 maj 2021, 16:31 u=C5=BCytkownik Larry Garfield napisa=C5=82: > On Mon, May 17, 2021, at 9:16 AM, Micha=C5=82 Marcin Brzuchalski wrote: > > pon., 17 maj 2021, 16:02 u=C5=BCytkownik tyson andre < > tysonandre775@hotmail.com> > > napisa=C5=82: > > > > > Hi internals, > > > > > > I've created a new RFC > > > https://wiki.php.net/rfc/enum_allow_static_properties > > > > > > Although enums are immutable objects, it is often useful to have > functions > > > or methods that operate on enum instances. > > > In many cases, it would make sense to declare that functionality as > static > > > methods on the enum itself. > > > In cases where static methods require shared state, it would be usefu= l > to > > > allow storing those shared state in static properties. > > > To ensure immutability of enum instances, it's only necessary to forb= id > > > instance properties, but all properties were forbidden in the initial > > > functionality included with the enums RFC. > > > > > > This RFC proposes allowing static properties in enums, while > continuing to > > > forbid instance properties. > > > > > > > Would you be able to provide more real life example? > > The example in RFC could easily encapsulate current Environment reading > in > > for eg. EnvironmentConfiguration class with static property and method > and > > TBH possibly that would be my preference to solve this. > > I would agree. Static properties are ugly to begin with. They're global= s > with extra syntax. I have no desire to see them on enums. > > Also a clarification, since it wasn't entirely clear in Tyson's original > email: Static methods on Enums *are already supported*. They were includ= ed > in the original Enum RFC. The change proposed here is just about static > properties. > Personally, I'd prefer to see enums as value objects only, adding static properties allow to implementation of statically conditional behaviour. IMO enums should consist only of pure functions. This is why I'd vote NO on this proposal. Cheers, Micha=C5=82 Marcin Brzuchalski > --000000000000cfdf6205c288a968--