Preg_match class name from PHP file
- by talentedmrjones
I have a script that recursively scans a directory pulling out class names from php files, and storing those classes names in an array. This is working nicely even through the rather large Zend Framework library folders.
The issue is that classes that extend other classes are not being included in the array.
Here is my current preg_match:
if (preg_match("/class\s*(\w*)\s*\{/i",strip_comments(file_get_contents($file)),$matches)) $classes[] = $matches[1];
I know that the last \s* is not right; there should be something there that can catch "{" or " extends Some_Other_Class {" .