Permalink
Browse files

Merge branch 'feature/ide-helper' into develop

  • Loading branch information...
2 parents e7abf32 + 6941836 commit b72fac53c6e615f2827a9f866329102b4c2ba38d @trq trq committed Apr 16, 2012
Showing with 27 additions and 0 deletions.
  1. +27 −0 Phakefile
View
27 Phakefile
@@ -55,7 +55,34 @@ group('dev', function() {
file_put_contents('lib/Proem/Api/Proem.php', $file);
}
});
+});
+desc('Generate a file of aliased definitions, helpful for IDEs that are having trouble with code completion');
+task('gen-ide-help', function() {
+ function recurseDir($path = '.')
+ {
+ $ignore = ['.', '..'];
+ $dh = @opendir($path);
+ while(false !== ($file = readdir($dh))) {
+ if (!in_array($file, $ignore)) {
+ if (is_dir("$path/$file")) {
+ recurseDir("$path/$file");
+ } else {
+ $filepath = "$path/$file";
+ foreach (file($filepath) as $line) {
+ if (preg_match('/^(class|abstract|trait)/', $line, $matches)) {
+ $type = $matches[1];
+ $class = str_replace(['lib/Proem/Api/', '.php', '/'], ['Proem/', '', '\\'], "$path/$file");
+ $extends = str_replace(['lib/', '.php', '/'], ['', '', '\\'], "$path/$file");
+ echo "$type $class extends $extends {}\n";
+ }
+ }
+ }
+ }
+ }
+ closedir( $dh );
+ }
+ recurseDir('lib');
});
task('default', 'dev:tests');

0 comments on commit b72fac5

Please sign in to comment.