Skip to content

Add self to HasCollection type param in Model#54311

Merged
taylorotwell merged 1 commit intolaravel:11.xfrom
thena-seer-sfg:patch-1
Jan 22, 2025
Merged

Add self to HasCollection type param in Model#54311
taylorotwell merged 1 commit intolaravel:11.xfrom
thena-seer-sfg:patch-1

Conversation

@thena-seer-sfg
Copy link
Copy Markdown
Contributor

Summary

Psalm is giving me this error when trying to extend the Model class.
Extended template param TModel of Illuminate\Database\Eloquent\Collection<array-key, static> expects type Illuminate\Database\Eloquent\Model, type static given (see https://psalm.dev/183)

The proposed change solves the error by indicating that whatever type resolved by static should also resolve as self AKA Model, according to the Collection template requirement.

My composer.json has:

        "php": "^8.3",
        "laravel/framework": "^11.0",
...
        "vimeo/psalm": "5.26.1",
        "psalm/plugin-laravel": "^2.11"

@taylorotwell taylorotwell merged commit 3c71a81 into laravel:11.x Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants