Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124991 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 AFEC81A00BD for ; Fri, 16 Aug 2024 19:39:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1723837287; bh=3ZM66L3ZKVJuL3v1fP7Z+krDjwqzhXA9S8QKe7hxUNQ=; h=Date:From:To:Subject:From; b=YC7tABUq+n6xlQnz7Nx4pxA7g+nW4TWALLU9LItnminoAfu015tgkgGdf6ptzfo6/ cX/L4HOt1k7NzyA/F6iTQAfGo6wq1BEsGPDIaMpxOeswUIj5SkEBPchn1NlybNiTTX OLuqJSCpGvd9cP1fvDOj3sP3JdS5hiOgRTW420wg+IVV+jytasN8RiDxe7qId11HPV EiwfIXDXjoWBP6ZG4HcpyvY7//jKpjdcjF5kbz3kPeA6ea/UE5MYkjHyNRweqeBAoK RTa26fTrLS5fafH2tdptH+IVNRINwSArEZO2F9BMlKRbtuDa0HnQvXy1GBevtyd4RK 3XS5HqWh6zZzg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6CD4F180072 for ; Fri, 16 Aug 2024 19:41:25 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 16 Aug 2024 19:41:23 +0000 (UTC) Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-6bf7ba05f75so11900636d6.0 for ; Fri, 16 Aug 2024 12:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coggenterprises-com.20230601.gappssmtp.com; s=20230601; t=1723837175; x=1724441975; darn=lists.php.net; h=mime-version:subject:message-id:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=3ZM66L3ZKVJuL3v1fP7Z+krDjwqzhXA9S8QKe7hxUNQ=; b=1BeRbUPGH+XtLUcNeU6kPlysBaIIjc+7SLceGtXx758X1LxhJaEy/UlgWhqOys1iVl G8HGJiBnq+UnbiIytDEHeun+AnINVGQvtIRZK4nX1T5FwS3o68ZUUrZqJCyHhvVjdm2T bZ6y8TBlFzA8xP3aeQJc2JTXSVDhH3c0hZy8xArTrIAq+8+xCYa46zmQ/wR3GZC2SqH4 Hvjm8whF1+decfpkoSX3wWSQYGjPCEP+oZkhRSofQ1ApAjd1Gpx2anadkL+vi53smDxX N3hbhpfEoZwg4+3H23+n9S19jxwaQZagT8Hv5dzYpI/wV1qz0kKEgDesmwXDROzj/tgn fwTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723837175; x=1724441975; h=mime-version:subject:message-id:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3ZM66L3ZKVJuL3v1fP7Z+krDjwqzhXA9S8QKe7hxUNQ=; b=ZtyP50TCu1HJrwHYx9JpT5o7ZWQab6kPdHYtz5I6jVtOi+JQVkwpdLwnkku8zdEbmV AKdJsTVfO8rO5f1tvgPcxC9HdPQUBDRjvngTaHNSeeja4Fa3S/RxMTmseOQJPtm4WCqr sUSv/wJ2aKbAmiilakaHov5cfVVcRmFyIkrOqSxgtsOgPJVlXxK0kY4Bl5M46CHXgTeV ok2LifF0wXySagTD76xU/RPqAhkV22m8GvMq4IxJvVs1USYzLZ7uU677VlrnTkl5mIDh jo2pCz8GNZBkJ4rUkoxfewQrIyedX8llDYb6UcjKH6WRbA3K0rpWaCkt5iqWBrvcooE1 DFvQ== X-Gm-Message-State: AOJu0YypwIB2kCa4YZ0hEGo4HBGUJTkBKUmkuA9K497bVJOXSFuQKslr HZCfCO4/aMKT7rekanU+kzj1BZccMLz4xrFtl+GZinn+WM23HevgYVB4EhBl9xsJUawWWuRyaj7 b X-Google-Smtp-Source: AGHT+IExSLupGXUcwbLriEeGOo2MTy73Snm/ihYKLnPtMPpckwcfe3R1cjplyDpiyWwcrK6A7y9YWA== X-Received: by 2002:a05:6214:2f0d:b0:6b5:7f19:e61d with SMTP id 6a1803df08f44-6bf7d50efcbmr102135436d6.6.1723837175057; Fri, 16 Aug 2024 12:39:35 -0700 (PDT) Received: from Johns-MacBook-Pro-2.local ([98.97.17.118]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bf6ff0c6b6sm20799036d6.141.2024.08.16.12.39.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 12:39:34 -0700 (PDT) Date: Fri, 16 Aug 2024 15:39:33 -0400 To: "=?utf-8?Q?internals=40lists.php.net?=" Message-ID: <2A3FFD56-789F-4ECF-8E9F-A84804E484D1@getmailspring.com> Subject: [PHP-DEV] String enums & __toString() X-Mailer: Mailspring Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="66bfaaf5_6b8b4567_17d67" From: john@coggeshall.org (John Coggeshall) --66bfaaf5_6b8b4567_17d67 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hey all, I poked around a bit in the Enum RFCs and I could find (maybe I missed) what's up with this: enum Foo:string implements \Stringable { case FOO = 'bar'; public function __toString() { return $this->value; } } PHP Fatal error: Enum Foo cannot include magic method __toString It seems to me that when the enum is a string it is entirely reasonable to expect __toString() to work here and support the \Stringable interface. Is there a reason I'm missing as to why this is problematic in the engine that's been documented somewhere, or is this an oversight we can look at correcting? John --66bfaaf5_6b8b4567_17d67 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hey all,

I poked around a bit in the Enum R=46Cs and I= could find (maybe I missed) what's up with this:

enum =46o= o:string implements =5CStringable
=7B
  &nb= sp; case =46OO =3D 'bar';

    public functio= n =5F=5FtoString() =7B
      &nbs= p; return =24this->value;
    =7D
=7D=

PHP =46atal error:  Enum =46oo cannot include magic m= ethod =5F=5FtoString

It seems to me that when the enum is a= string  it is entirely reasonable to expect =5F=5F= toString()  to work here and support the =5CStringable<= /code>  interface.

Is there a reason I'm missing as t= o why this is problematic in the engine that's been documented somewhere,= or is this an oversight we can look at correcting=3F

John<= /div> --66bfaaf5_6b8b4567_17d67--