簡単なenum書いた

<?php
class Enum
{
    protected $namelist = array(), $currentnum = 0;
    static function create(Array $arr)
    {
        $ins = new self;
        foreach ($arr as $name) $ins->add($name);
        return $ins;
    }
    function add($name, $num = null)
    {
        if (!is_null($num)) $this->currentnum = $num;
        if (isset($this->namelist[$name])) throw new Exception;
        $this->namelist[$name] = $this->currentnum++;
        return $this;
    }
    function get($name)
    {
        if (!isset($this->namelist[$name])) throw new Exception;
        return $this->namelist[$name];
    }
    function __get($name)
    {
        return $this->get($name);
    }
}

function enum()
{
    return Enum::create(func_get_args());
}

使い方

<?php
$hoge = @enum(Hoge, Fuga, Piyo, Foo);
// もしくは $hoge = enum('Hoge', 'Fuga', 'Piyo', 'Foo');
$hoge->Hoge;  //=>0
$hoge->Piyo;  //=>2

$hoge->add(@Bar, 10);
// もしくは $hoge->add('Bar', 10);
$hoge->Bar;  //=>10

@を使うと結構スマートにかける。ただし、予約語や定数として登録されているものを使いたい時は素直にクオートする必要あり。