New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should ide-helper:models be generating phpDoc for the magic Eloquent\Model static methods? #259
Comments
I'll works if you extends from |
I think that having such methods in Model docblocks is a real overhead, because find is only one "magic" method from EloquentBuilder. Then somebody will want methods from the QueryBuilder which are also called with __call/__callStatic. So the easiest workaround, if you need autocompletion, is to extend /**
* App\User
*
* @mixin Eloquent
*/ |
Aha, such a tricky but useful workaround ~ |
I believe |
@Francismori7 Agreed. |
I have 5.1 and a BaseModel in the inheritance chain which extends from Eloquent. Even with this the methods like find will always make the ide think that the class returned is Eloquent/Model rather than the calling model class. We have over 1K models encompassing our sites to sales to warehousing to logistics. For our 50+ developers this plugin is a godsend but imagine adding the two static method definitions we use the most to the models when a scheduled reset is run through artisan(!) and then you can understand how a godsend turns into a god's wrath... @method static [model class]|null first($columns = array())
@method static [model class]|null find($id) |
It's help author to close many issues! ) Like: barryvdh#269, barryvdh#259, barryvdh#248, barryvdh#209, barryvdh#191, barryvdh#74, and laravel/framework#7558 ))) etc. maybe
@barryvdh this is already fixed due to |
I have recently setup a new Lumen project (v5.1.3) and noticed the instance methods from
Eloquent\Builder
provided toEloquent\Model
by usingModel::__callStatic()
andModel->__call()
internally are not added to the phpDocs generated byide-helper:models
.One example directly from the Larvel 5.1 documentation is the
::find()
method.My observation is this call to ::find() is caught by
__callStatic()
and__call()
methods of Eloquent\Model and proxied to\Illuminate\Database\Eloquent\Builder
.These methods can be added to the phpDocs of the model with @method hints like the following:
My question is, should these magic methods from Builder be added to Model subclasses by
ide-helper:models
? Or should the Laravel documentation be updated instead?Worth noting that this whole situation can also be avoided by using the builder directly via the
query()
method.The text was updated successfully, but these errors were encountered: