Skip to content

Minor: RepositoryInterface generic #520

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

Open
1 task done
rincler opened this issue Apr 29, 2025 · 3 comments · May be fixed by #524
Open
1 task done

Minor: RepositoryInterface generic #520

rincler opened this issue Apr 29, 2025 · 3 comments · May be fixed by #524
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@rincler
Copy link

rincler commented Apr 29, 2025

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

Could you please make a small update to RepositoryInterface?

Change @template TEntity to @template TEntity of object just like it's done in Repository.

I'm experiencing an issue with PHPStan: https://phpstan.org/r/b906c8b7-d85c-44d6-bcb0-9b7828da8d9f
I'm particularly concerned about this error:

Call to an undefined method object::getStatus().

Adding @template TEntity of object on line 4 resolves the issue.

Thanks!

Version

ORM 2.10.0
PHP 8.3
@rincler rincler added status:to be verified Needs to be reproduced and validated. type:bug Bug labels Apr 29, 2025
@rincler rincler changed the title Minior: RepositoryInterface generic Minor: RepositoryInterface generic Apr 29, 2025
@roxblnfk
Copy link
Member

I think it was of object there. But I removed it because of Psalm errors.
If we specify the type object, another problem arises about variance. PHPStan might be a bit weak or flex in this area, but not Psalm:

  • If we write @template TEntity of object, we can't use TEntity in the return type.
  • If we write @template-covariant TEntity of object, we can't use TEntity in parameters.

@rincler
Copy link
Author

rincler commented Apr 30, 2025

Could you provide an example where Psalm behaves differently? I copied my code into the Psalm sandbox, and it works with TEntity of object: https://psalm.dev/r/4bec47759a.
Also, why is it TEntity of object in Repository, but just TEntity in RepositoryInterface?

@roxblnfk
Copy link
Member

roxblnfk commented May 1, 2025

Looks like it was fixed in https://github.com/vimeo/psalm/releases/tag/6.5.0 or earlier
Feel free to make a PR with type fixes

@rincler rincler linked a pull request May 15, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants