Just FYI, the [PHP documentation](http://php.net/manual/en/language.oop5.basic.php) provides a regular expression for matching valid class names. Of course you need to extend this a bit, but it's a good starting point.

> The class name can be any valid label which is not a PHP reserved word. A valid class name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.