laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Removing extends from generated class breaks autocomplete

Open Jefemy opened this issue 2 years ago • 4 comments

Versions:

  • ide-helper Version: 2.11.0
  • Laravel Version: 8.79.0
  • PHP Version: 8.0

Description:

https://github.com/barryvdh/laravel-ide-helper/pull/1268 changed mixin mode to not add an extends to the generated class. This breaks the autocomplete for functions like Model->find() as my classes no longer extend \Eloquent

Steps To Reproduce:

  • Run ide-helper:models -M
  • Try to use the find() function on any model and see that the return type is listed as mixed instead of the proper class

Jefemy avatar Jan 17 '22 20:01 Jefemy

Can you use --write to write this to the model files directly? Or at least, can you test if it elevates the problem?

mfn avatar Jan 18 '22 07:01 mfn

After running that command it appears to have fixed it even after reverting back to just the -M command. Must have just been an issue with my IntelliSense extension.

Jefemy avatar Jan 20 '22 01:01 Jefemy

Actually I do think this is an issue. After looking into it some more I realized my output doesn't include the @mixin \Eloquent that the test case includes here.

This appears to be caused by the line here where it ignores adding the tag if there is a mixin present in the Model class, which there always will be after the first run since the command writes a mixin.

The commit adding it mentions its for preventing duplicate mixin tags but shouldn't it only be checking for tags with the \Eloquent class?

Jefemy avatar Jan 28 '22 11:01 Jefemy

@Jefemy I think this was introduced in #1268

edcoreweb avatar Mar 17 '22 22:03 edcoreweb