Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HasOneDeep is not generic #223

Closed
ahoiroman opened this issue Dec 18, 2023 · 5 comments
Closed

HasOneDeep is not generic #223

ahoiroman opened this issue Dec 18, 2023 · 5 comments

Comments

@ahoiroman
Copy link
Contributor

I got this relation:

    /**
     * @return HasOneDeep<Key>
     */
    public function key(): HasOneDeep
    {
        return $this->hasOneDeepFromRelations($this->vault(), (new Vault())->key());
    }

But unfortunately, phpstan reports:

phpstan: PHPDoc tag @return contains generic type Staudenmeir\EloquentHasManyDeep\HasOneDeep<App\Models\Key> but class Staudenmeir\EloquentHasManyDeep\HasOneDeep is not generic.

What can I do about it?

@staudenmeir
Copy link
Owner

Hi @ahoiromanm
Does the issue go away if you add this comment to vendor/staudenmeir/eloquent-has-many-deep/src/HasOneDeep.php?

/**
 * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
 * @extends \Illuminate\Database\Eloquent\Relations\HasOneThrough<TRelatedModel>
 */
class HasOneDeep extends HasManyDeep
{

@ahoiroman
Copy link
Contributor Author

Hi Jonas,

unfortunately it is not solving the problem. The error is exactly the same.

@staudenmeir
Copy link
Owner

Could be a caching issue, it works for me. Please run vendor/bin/phpstan clear-result-cache and try again.

@ahoiroman
Copy link
Contributor Author

You are right. After clearing the cache it works with the changes you described.

@staudenmeir
Copy link
Owner

Great. I've released a new version with the comment.

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

No branches or pull requests

2 participants