Closed Maschga closed 5 months ago
When intelephense comes across a name clash like this it treats the classes as partial classes and merges them. However it doesn't accept multiple inheritance which is what is happening here by extending \Eloquent
in one and Model
in the other. It did in the previous versions but it became too complex with addition of other features like templates.
To resolve this you can either:
\Eloquent
in your real models. I believe laravel sets this as a runtime alias for Illuminate\Database\Eloquent\Model
anyway, and then it will pickup the methods defined on \Eloquent
in the ide helper files.@mixin \Eloquent
to the docblock of your model.
Hi!
Describe the bug I have a Laravel-Project (Version 10) for which I use VSCode (Version 1.88.0) and PHP Intelephense. This framework has its own ORM called Eloquent. Every table in a database is represented by a class in PHP which inherits from the
Illuminate\Database\Eloquent\Model
-class. In my example below I created anAppointment
-model. With these classes you are able to filter the entries in the table (for example with theAppointment::find()
-method) or to retrieve all entries from the table (for example with theAppointment::all()
-method). However, theIlluminate\Database\Eloquent\Model
-class does not define the methods with which you are able to filter the entries. So in my example the IDE would only be able to autocomplete the methodall()
but not the (nevertheless available)where()
-method. Therefore, theLaravel-IDE-Helper
-package creates two files (_ide_helper.php
and_ide_helper_models.php
) to define the filter-methods and to make them visible for the IDE and tools like PHP Intelephense. However this does not work for the current version of PHP Intelephense (1.10.4). So I tried other versions and found out that the versions1.0.1 - 1.8.2
do not raise any errors but the versions1.9.0 - 1.10.4
do so. Unfortunately, I don't have any clue why PHP Intelephense does not recognize these methods any more or whether I'm doing something wrong. I had a look at theCHANGELOG.md
but I didn't find something interesting. That's why the title of this issue is not very informative (feel free to change the title to a better one).To Reproduce I created four files to reproduce it:
Appointment.php
:Model.php
:_ide_helper_models.php
:_ide_helper.php
:You might want to download this
.zip
so you do not have to create these files: src.zipExpected behavior The
where()
-method should be found from PHP Intelephense and shown in the autocompletion-popup.Screenshots Autocompletion when using the version
1.8.2
: Autocompletion when using the version1.10.4
:Platform and version OS: Windows 10, Intelephense version specified above
Thank you in advance! ~ Maschga