Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125005 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 1BD741A00BD for ; Fri, 16 Aug 2024 22:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1723848681; bh=UhQGv/zAoztw+kJNi76MDaRo4K0+KOrCIIfqofmDgxY=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=LD7R/DfJQ82rmgKP8JPs8FG6eZRXfZhStmblPNNoXuWdTiMl3VhQe9hBZVylI2kK1 5281kFFUkKV5pSmXQoQnA8GAVt137TuI5dVKNRF6qfnSUqqhdTqGCEJhjQ/xDcZFwA FAyKUjoqrk/VxLhyOIZ79CwXo1zj6AeUcjA8GTRMA3NwjL0QpvQPT2LYidx3orkC5e ocGqHwni/ZYHSsmAvPGcOH+D8l+PG3IiOZIVT1trghtr9Rj4/40Puc3YGEuuX35Zhc ZGF3KU3p6GKa/lBOdSRZ6wxgUj/DEPF4pfWiCPxl3lfkCfRpyMxLVDPPx4wz/bQJUy pdRVe9quejTow== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C4CC71801DF for ; Fri, 16 Aug 2024 22:51:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout7-smtp.messagingengine.com (fout7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 16 Aug 2024 22:51:16 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id F2113138FC64; Fri, 16 Aug 2024 18:49:28 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-03.internal (MEProxy); Fri, 16 Aug 2024 18:49:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1723848568; x= 1723934968; bh=StxylGFjvvtXB8YuV7PFy9tH2cG7llBm/s7OVfZ92Ys=; b=G zJVfHEfP6gbDqkV8lQjI/ZLgTsM03ltSabGJ/pR45POmYJcI7T+fY8CI23rtqD4t q21DW4Fn3/gxCqELQRhFiJpBhyiiMMvRJ9nbOsBp21iXfgZ+JmkB4o0gzFdWnp68 JDiYxv59gCtZytOw0chlFj2b5+obnq0qnNel3nx703R87EaEaM2MI64fiPm69wqG O+AphIeOrkSO9WdRwEX98S2Xan8vyHjhASR6yu3o6JcJ93jvQvaOMtgalZCVwv7h CRAyFv65SEG5+7GopG2Dgtw4aGX6Y2/ch7JUwwaodV8/ueXV4kw2rSvfT+isp9gK 1Tj9SRVTEPlrTJ6poXUvg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1723848568; x=1723934968; bh=StxylGFjvvtXB8YuV7PFy9tH2cG7 llBm/s7OVfZ92Ys=; b=bN9IZ50RxOC56ZQdl93ROvrBOLad2JobIvEPkNZUoMb2 WSP93wmVFjkFQpyTJeNQMYj9Cx5CG+rdDeGAAy5OIOohgvNyPge4oxHvLMxVMu9C mQYDSbl9hX8+Pt8Mh1+ro2wvO4Yz7s4G//iKrSrMeAymVzJf7Bd+R4OKMndfiS7C cG3dLg+8VNV2fCj1F7Xv0tkhiON8fTkX4HK3tNd8/gmEGncAYFtH+8YYaoOgf99P 1G4LlHwANQsR+HUvpP7oC4Vw76xoOYuxHhtm282N4wc1rP5gaIEpvQMnv1AL8ZYO XJwEChBNQyE/u6vynxs0J6+/TvscoKNRnorUbqIcwQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtledgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgesrgdtreerredtjeen ucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtoh guvghsqeenucggtffrrghtthgvrhhnpeffgeevveegtdffgfffvdfftddvheeuleegveek teffueeliedtgeekjeettdetkeenucffohhmrghinhepphhhphdrnhgvthenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhl vggurdgtohguvghspdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehjohhhnhestghoghhgvghshhgrlhhlrdhorhhgpdhrtghpthhtohepihhn thgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvthdprhgtphhtthhopegsihhlghgvse hstghrihhpthhfuhhsihhonhdrtghomh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id C4A0215A005E; Fri, 16 Aug 2024 18:49:28 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Sat, 17 Aug 2024 00:49:05 +0200 To: "John Coggeshall" , Bilge Cc: "internals@lists.php.net" Message-ID: In-Reply-To: <59BED9FD-EB77-4B44-9F93-7FC573EC7F14@getmailspring.com> References: <501db7d2-55e1-4b20-bb6e-1e079aa4939b@scriptfusion.com> <59BED9FD-EB77-4B44-9F93-7FC573EC7F14@getmailspring.com> Subject: Re: [PHP-DEV] String enums & __toString() Content-Type: multipart/alternative; boundary=b78e722581454cd8af08e7da36f61c29 From: rob@bottled.codes ("Rob Landers") --b78e722581454cd8af08e7da36f61c29 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Aug 16, 2024, at 21:57, John Coggeshall wrote: >> Didja really? >>=20 >> https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_= enums > I swear I did. >=20 > That said, looking at that RFC it's a slightly different take than wha= t I am suggesting. This RFC suggests that `string` enums automatically = implement `Stringable` . I am pointing out that it's a little silly IMO = that we don't allow `__toString()` at all and let the developer choose = if they want to implement `Stringable` . Looking through the PR comments= it's pretty clear there was a decent amount of support for this alterna= tive idea. It also looks like the PR for this died on the vine and I'm c= urious is there is any interest in reviving the discussion? >=20 > I'm not seeing an obvious upside to forbidding straight out `__toStrin= g()` , especially (as is pointed out in the PR comments) that you can us= e other native interfaces like `JsonSerializable` without issue. Hello, I personally find it an interesting design choice. I agree with it, and = disagree with it at the same time. Like, anytime I find myself wanting t= o reach for enums as strings, I realize I want a constant instead. But t= hen someone sees a string type and manually types it instead of using th= e constant (heh, I=E2=80=99ve been guilty of that myself a few times). That being said, I would like to be able to use | and & on integer enums= more than I would strings as stringables. Something like =E2=80=9Cflags= =E2=80=9D mode in C#. Maybe even make =E2=80=9Cflag=E2=80=9D a backing t= ype of enums. It would make a ton of json flags much simpler to reason a= bout (and filters/sanitizers). =E2=80=94 Rob --b78e722581454cd8af08e7da36f61c29 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable