Seperated generated file from package. Added --sublime option

This way the package will be updated less, and you don't have double IDE
helpers (in you vendor dir, and the generated version).
Also added a Sublimetext version, with different way of calling the root
class.
This commit is contained in:
Barry
2013-03-23 15:07:57 +01:00
parent beed27073a
commit bcde5334ba
3 changed files with 27 additions and 9171 deletions
-9162
View File
File diff suppressed because it is too large Load Diff
+8 -2
View File
@@ -2,8 +2,10 @@
### Complete phpDocs, directly from the source ### Complete phpDocs, directly from the source
Add the _IDE_helper.php to your laravel folder (not in a public folder). The file isn't used by Laravel, but it has to be indexed by your IDE. Add the helper file to your laravel folder (not in a public folder). The file isn't used by Laravel, but it has to be indexed by your IDE.
The file has been tested in Netbeans 7.3 and PHPStorm 6.
Netbeans 7 and PHPStorm 6 version: https://gist.github.com/barryvdh/5227822
SublimeText CodeIntel version: https://gist.github.com/barryvdh/5227814
### Automatic phpDoc generation for Laravel Facades ### Automatic phpDoc generation for Laravel Facades
@@ -19,6 +21,10 @@ You can now re-generate the docs yourself (for future updates) in arisan
php artisan ide-helper:generate php artisan ide-helper:generate
If you use SublimeText CodeIntel, the format is a bit different. So add --sublime (or -S) to your command
php artisan ide-helper:generate -S
You can also publish the config-file to add extra facades (ie. for bundles). You can also publish the config-file to add extra facades (ie. for bundles).
php artisan config:publish barryvdh/laravel-ide-helper php artisan config:publish barryvdh/laravel-ide-helper
@@ -41,7 +41,7 @@ class GeneratorCommand extends Command {
$helpers = array(); $helpers = array();
} }
$content = $this->generateDocs($aliases, $helpers); $content = $this->generateDocs($aliases, $helpers, $this->option('sublime'));
$written = \File::put($filename, $content); $written = \File::put($filename, $content);
@@ -84,10 +84,11 @@ class GeneratorCommand extends Command {
return array( return array(
array('helpers', "H", InputOption::VALUE_NONE, 'Include the helper files'), array('helpers', "H", InputOption::VALUE_NONE, 'Include the helper files'),
array('nohelpers', "N", InputOption::VALUE_NONE, 'Do not include the helper files'), array('nohelpers', "N", InputOption::VALUE_NONE, 'Do not include the helper files'),
array('sublime', "S", InputOption::VALUE_NONE, 'Use different style for SublimeText CodeIntel'),
); );
} }
protected function generateDocs($aliases, $helpers = array()){ protected function generateDocs($aliases, $helpers = array(), $sublime = false){
$d = new Parser(); $d = new Parser();
$d->setAllowInherited(true); $d->setAllowInherited(true);
$d->setMethodFilter(\ReflectionMethod::IS_PUBLIC); $d->setMethodFilter(\ReflectionMethod::IS_PUBLIC);
@@ -112,13 +113,18 @@ class GeneratorCommand extends Command {
$d->analyze($root); $d->analyze($root);
$output .= "namespace $namespace {\n class $alias{\r\n"; $output .= "namespace $namespace {\n";
$output .= "\t/**\n\t * @var $root \$root\n\t */\n\t static private \$root;\n\n"; if($sublime){
$output .= " class $alias extends $root{\n";
}else{
$output .= " class $alias{\n";
$output .= "\t/**\n\t * @var $root \$root\n\t */\n\t static private \$root;\n\n";
}
$methods = $d->getMethods(); $methods = $d->getMethods();
foreach ($methods as $method) foreach ($methods as $method)
{ {
$output .= $this->parseMethod($method); $output .= $this->parseMethod($method, $sublime);
} }
$output .= " }\n}\n\n"; $output .= " }\n}\n\n";
@@ -135,7 +141,7 @@ class GeneratorCommand extends Command {
return $output; return $output;
} }
protected function parseMethod($method){ protected function parseMethod($method, $sublime=false){
if($method->name === '__clone'){ if($method->name === '__clone'){
return ''; return '';
} }
@@ -195,7 +201,13 @@ class GeneratorCommand extends Command {
} }
$output .= implode($paramsWithDefault, ", "); $output .= implode($paramsWithDefault, ", ");
$output .= "){\r\n\t\t".($returnValue !== "void" ? 'return ' : '')."self::\$root->".$method->name."(".implode($params, ", ").");\r\n\t }\n\n"; $output .= "){\r\n\t\t".($returnValue !== "void" ? 'return ' : '');
if($sublime){
$output .= "parent::";
}else{
$output .= "self::\$root->";
}
$output .= $method->name."(".implode($params, ", ").");\r\n\t }\n\n";
return $output; return $output;
} }