barryvdh / laravel-ide-helper

IDE Helper for Laravel
MIT License
14.17k stars 1.16k forks source link

Improve replacement of return type for methods from Query\Builder #1575

Open pjio opened 2 months ago

pjio commented 2 months ago

Summary

See issue for expected improvement: https://github.com/barryvdh/laravel-ide-helper/issues/1574

The class \Eloquent in _ide_helper.php contains methods from Illuminate\Database\Eloquent\Builder and Illuminate\Database\Query\Builder. The return type for $this is replaced with the real class (in case of the Eloquent\Builder already with an additional |static). This merge requests replaces $this in methods from Query\Builder with the identical return type Illuminate\Database\Eloquent\Builder|static. In the context of an \Eloquent instance this should be the real behavior and improves the derived types.

Type of change

Checklist

pjio commented 2 months ago

Here the old and new file for easier comparison: _ide_helper.php.old.txt _ide_helper.php.new.txt

eldair commented 1 month ago

@pjio will this fix https://github.com/barryvdh/laravel-ide-helper/issues/1572 as well?

pjio commented 1 month ago

@pjio will this fix #1572 as well?

No, for #1572 it doesn't make a difference. The cause is a different one. This PR only affects the return type $this.

pjio commented 1 month ago

Changes 03.09.24

Edit: Intelephense up to version 1.10.4 and again since version 1.12.6 works with the |static return type.

CongAn commented 4 weeks ago

Thank you very much for your valuable contributions! I would greatly appreciate it if the project maintainers could merge this pull request and release a new version as soon as possible.