Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57932 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33114 invoked from network); 22 Feb 2012 06:02:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2012 06:02:31 -0000 Authentication-Results: pb1.pair.com header.from=charlie@charliesomerville.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=charlie@charliesomerville.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain charliesomerville.com from 74.125.82.170 cause and error) X-PHP-List-Original-Sender: charlie@charliesomerville.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:35351] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/31-16342-DE4844F4 for ; Wed, 22 Feb 2012 01:02:24 -0500 Received: by werm1 with SMTP id m1so5337909wer.29 for ; Tue, 21 Feb 2012 22:02:16 -0800 (PST) Received-SPF: pass (google.com: domain of charlie@charliesomerville.com designates 10.180.89.71 as permitted sender) client-ip=10.180.89.71; Authentication-Results: mr.google.com; spf=pass (google.com: domain of charlie@charliesomerville.com designates 10.180.89.71 as permitted sender) smtp.mail=charlie@charliesomerville.com Received: from mr.google.com ([10.180.89.71]) by 10.180.89.71 with SMTP id bm7mr32754926wib.20.1329890536164 (num_hops = 1); Tue, 21 Feb 2012 22:02:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.89.71 with SMTP id bm7mr27314033wib.20.1329890536079; Tue, 21 Feb 2012 22:02:16 -0800 (PST) Received: by 10.180.5.6 with HTTP; Tue, 21 Feb 2012 22:02:16 -0800 (PST) Received: by 10.180.5.6 with HTTP; Tue, 21 Feb 2012 22:02:16 -0800 (PST) In-Reply-To: References: Date: Wed, 22 Feb 2012 17:02:16 +1100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d04447e0bfe3f6d04b98744f7 X-Gm-Message-State: ALoCoQkEoAFeEqHgNAJyn3twpiNg01cFdwP2MSOEB+F+lLb2xsJ/IUqDCsRRPDNPmW7MNoMd9m+3 Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: charlie@charliesomerville.com (Charlie Somerville) --f46d04447e0bfe3f6d04b98744f7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Right, but enums could possibly be a lot richer than class constants are now. They could be a type where the only values are what's defined in the enum. This could be used with type hinting: enum Foo { A, B, C } function bar(Foo $x) { // ... } There'd be no need to do any manual checking that $x is a valid value. Perhaps enum values could also be casted back to strings: (string)Foo::B; // "B" Sure, this is the kind of stuff that's possible in other ways already, but first class support always helps. On Feb 22, 2012 4:14 PM, "Laruence" wrote: > On Wed, Feb 22, 2012 at 12:45 PM, Samuel Deal > wrote: > > Hi all, > > > > I really missed enums in PHP, > Why? we have class constant. > > thanks > > So after reading I tryed to synthetise the various views. > > > > You can find a draft here : > > https://github.com/SamNrique/php-src/wiki/RFC-draft > > (I can't write on the wiki, and perhaps it's better to finish the > > discussion first) > > > > There's an implementation with this draft. > > I'd love to have feedbacks because it's my first php-core hack. > > > > Thanks > > -- > > Samuel D=C3=A9al > > samuel.deal@gmail.com > > > > -- > Laruence Xinchen Hui > http://www.laruence.com/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --f46d04447e0bfe3f6d04b98744f7--