<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Tue, 18 Jun 2013 22:58:30 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Benjamin Eberlei's Blog: Enums in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/13144</guid>
      <link>http://www.phpdeveloper.org/news/13144</link>
      <description><![CDATA[<p>
In a <a href="http://www.whitewashing.de/blog/articles/120">new post</a> to his blog <i>Benjamin Eberlei</i> talks about enum data types in PHP and how the <a href="http://us.php.net/splenum">is getting close</a> but still isn't quite there yet.
</p>
<blockquote>
If you want to implement Enum behaviour with a simple string or int value you end up with having to validate the values at several different locations in the code rather than being able to strictly enforce the Enum structure by using typehints.
</blockquote>
<p>
In an effort to try to help the situation he and a colleague came up with an abstract class MyEnum that uses the <a href="http://us.php.net/manual/en/language.oop5.magic.php">__toString</a> method to do value checking. Code examples are included for the class and how to use it.
</p>]]></description>
      <pubDate>Tue, 01 Sep 2009 12:46:34 -0500</pubDate>
    </item>
  </channel>
</rss>
