Merge sublime and netbeans/phpstorm

Gives some warnings for phpStorm, but only in the helper file, so
doesn't affect the autocomplete / warnings in application code.
This commit is contained in:
Barry vd. Heuvel
2013-06-06 13:45:05 +02:00
parent 2ee05260d5
commit 0b3b8b95cd
2 changed files with 9 additions and 20 deletions
+3 -7
View File
@@ -4,10 +4,10 @@
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. 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.
* Netbeans and PHPStorm version: https://gist.github.com/barryvdh/5227822 * Generated 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
#### NOTE: run before optimising. If bootstrap/compiled.php is loaded, it doesn't work. #### NOTE: run before optimising. If bootstrap/compiled.php is loaded, it doesn't work.
php artisan clear-compiled php artisan clear-compiled
@@ -26,10 +26,6 @@ You can now re-generate the docs yourself (for future updates) in artisan
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
Note: You do need CodeIntel for Sublime Text: https://github.com/Kronuz/SublimeCodeIntel Note: You do need CodeIntel for Sublime Text: https://github.com/Kronuz/SublimeCodeIntel
You can configure your composer.json to do this after each commit: You can configure your composer.json to do this after each commit:
@@ -37,7 +33,7 @@ You can configure your composer.json to do this after each commit:
"scripts":{ "scripts":{
"post-update-cmd":[ "post-update-cmd":[
"php artisan ide-helper:generate", "php artisan ide-helper:generate",
"php artisan optimize" "php artisan optimize",
] ]
}, },
@@ -42,7 +42,6 @@ class GeneratorCommand extends Command {
protected $nonstatic; protected $nonstatic;
protected $onlyExtend; protected $onlyExtend;
protected $helpers; protected $helpers;
protected $sublime;
/** /**
@@ -71,8 +70,6 @@ class GeneratorCommand extends Command {
$this->helpers = array(); $this->helpers = array();
} }
$this->sublime = $this->option('sublime') || \Config::get('laravel-ide-helper::sublime');
$content = $this->generateDocs(); $content = $this->generateDocs();
$written = \File::put($filename, $content); $written = \File::put($filename, $content);
@@ -116,7 +113,7 @@ 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('memory', "M", InputOption::VALUE_NONE, 'Use sqlite memory driver'), array('memory', "M", InputOption::VALUE_NONE, 'Use sqlite memory driver'),
array('sublime', "S", InputOption::VALUE_NONE, 'Use different style for SublimeText CodeIntel'), array('sublime', "S", InputOption::VALUE_NONE, 'DEPRECATED: Use different style for SublimeText CodeIntel'),
); );
} }
@@ -180,7 +177,6 @@ namespace {\n\tdie('Only to be used as an helper for your IDE');\n}\n\n";
}else{ }else{
$output .= " class $alias{\n"; $output .= " class $alias{\n";
} }
$output .= "\t/**\n\t * @var \\$root \$root\n\t */\n\t static private \$root;\n\n";
if(!in_array($alias, $this->onlyExtend)) if(!in_array($alias, $this->onlyExtend))
{ {
@@ -313,11 +309,11 @@ namespace {\n\tdie('Only to be used as an helper for your IDE');\n}\n\n";
if($method->name == "__construct"){ if($method->name == "__construct"){
$returnValue = 'self'; $returnValue = 'self';
}elseif(!$this->sublime and $alias == 'Eloquent' and }elseif($alias == 'Eloquent' and
(in_array($method->name, array('pluck', 'first', 'fill', 'newInstance', 'newFromBuilder', 'create', 'find', 'findOrFail')) (in_array($method->name, array('pluck', 'first', 'fill', 'newInstance', 'newFromBuilder', 'create', 'find', 'findOrFail'))
or $returnValue === '\Illuminate\Database\Query\Builder')){ or $returnValue === '\Illuminate\Database\Query\Builder')){
//Reference the calling class, to provide more accurate auto-complete //Reference the calling class, to provide more accurate auto-complete
$returnValue = "static"; $returnValue .= "static";
}elseif($alias == 'Eloquent' and in_array($method->name, array('all', 'get'))){ }elseif($alias == 'Eloquent' and in_array($method->name, array('all', 'get'))){
$returnValue .= "|\Eloquent[]|static[]"; $returnValue .= "|\Eloquent[]|static[]";
}elseif($alias == 'Eloquent' and in_array($method->name, array('hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphOne', 'morphTo', 'morphMany'))){ }elseif($alias == 'Eloquent' and in_array($method->name, array('hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphOne', 'morphTo', 'morphMany'))){
@@ -357,11 +353,8 @@ namespace {\n\tdie('Only to be used as an helper for your IDE');\n}\n\n";
$return = ($returnValue && $returnValue !== "void" && $method->name !== "__construct") ? 'return' : ''; $return = ($returnValue && $returnValue !== "void" && $method->name !== "__construct") ? 'return' : '';
if($this->sublime){
$output .= "\t\t$return $root->"; $output .= "\t\t$return $root::";
}else{
$output .= "\t\t$return static::\$$rootParam->";
}
$output .= $method->name."(".implode($params, ", ").");\r\n"; $output .= $method->name."(".implode($params, ", ").");\r\n";