larastan / larastan

⚗️ Adds code analysis to Laravel improving developer productivity and code quality.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eloquent\Collection concat() returns Eloquent\Collection, gets typed as Support\Collection

Grldk opened this issue · comments

  • Laravel Version: 10.48.4
  • Larastan Version: 2.9.2
  • --level used: 8

Description

Similar to #1731, after upgrading larastan to 2.9.2 (from 2.6.x I think) I've gotten a couple of new errors regardingEloquentCollection@concat

Laravel code where the issue was found

use Illuminate\Database\Eloquent\Collection as EloquentCollection;

        if ($collection instanceof EloquentCollection) {
            \PHPStan\dumpType($collection);

            $collection = $collection
                ->concat([new User()])
            ;

            \PHPStan\dumpType($collection);
        }

Dumped type before concat: Illuminate\Database\Eloquent\Collection<int, App\Models\User>
Dumped type after concat Illuminate\Support\Collection<int, App\Models\User>

Expected type after concat: Illuminate\Database\Eloquent\Collection<int, App\Models\User>