Closed HugoSuarezJr closed 1 week ago
I think the problem is that paginate
returns \Illuminate\Contracts\Pagination\LengthAwarePaginator
which does not have this method declared. (You can hover on paginate to check this).
https://github.com/laravel/framework/blob/11.x/src/Illuminate/Contracts/Pagination/LengthAwarePaginator.php
You could assign the result on paginate
to a variable and narrow the type like so:
/** @var \Illuminate\Pagination\AbstractPaginator $paginator */
$paginator = $query->paginate(10);
//or alternatively
if ($paginator instanceof \Illuminate\Pagination\AbstractPaginator) {
$projects = $paginator->onEachSide(1);
}
Or you could fool the extension by adding the onEachSide
method to the \Illuminate\Contracts\Pagination\LengthAwarePaginator
interface in a (non-executable) stub file. For example
intelephense_helper.php
namespace Illuminate\Contracts\Pagination;
interface LengthAwarePaginator {
function onEachSide($param) {};
}
Describe the bug Intelephense says undefined method 'onEachSide' for the Illuminate\Database\Eloquent\Collection::onEachSide method.
To Reproduce
$projects = Project::query()->paginate(10)->onEachSide(1);
Expected behavior There should be no Intelephense error as this is a defined method and the code works just fine but it displays as if it were wrong in VScode.
Screenshots![Screenshot 2024-06-25 at 5 42 34 PM](https://github.com/bmewburn/vscode-intelephense/assets/62357383/0b1693c4-f24c-416d-b853-4637afe8cf40)
Platform and version VSCode and PHP Intelephense v1.10.4