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

Class with generic mixin gives unexpected results #8008

Closed
erikgaal opened this issue Sep 14, 2022 · 2 comments
Closed

Class with generic mixin gives unexpected results #8008

erikgaal opened this issue Sep 14, 2022 · 2 comments
Labels
Milestone

Comments

@erikgaal
Copy link

Bug report

I'm trying to implement the types for Pagination in Laravel, but I'm running into some issues with mixins.
It seems that types aren't resolved when a concrete class with a generic has a mixin and passes the generic through.

I've attached an example on phpstan.org that explains the situation.

Not sure if this is a bug or a feature request. Would be happy to try and solve this issue with some directions though!

Code snippet that reproduces the problem

https://phpstan.org/r/6bc14eb5-a2ad-46be-923e-c33c7441317a

Expected output

Expected type array<MyObject>, actual: array<TValue of object (class Paginator, parameter)>
@ondrejmirtes ondrejmirtes added this to the Generics milestone Sep 21, 2022
@phpstan-bot
Copy link
Contributor

@erikgaal After the latest push in 1.9.x, PHPStan now reports different result with your code snippet:

@@ @@
-PHP 8.0 – 8.2 (1 error)
+PHP 8.0 – 8.2
 ==========
 
-57: Expected type array<MyObject>, actual: array<TValue of object (class Paginator, parameter)>
+No errors
 
-PHP 7.1 – 7.4 (3 errors)
+PHP 7.1 – 7.4 (2 errors)
 ==========
 
 13: Promoted properties are supported only on PHP 8.0 and later.
-41: Promoted properties are supported only on PHP 8.0 and later.
-57: Expected type array<MyObject>, actual: array<TValue of object (class Paginator, parameter)>
+41: Promoted properties are supported only on PHP 8.0 and later.
Full report

PHP 8.0 – 8.2

No errors

PHP 7.1 – 7.4 (2 errors)

Line Error
13 Promoted properties are supported only on PHP 8.0 and later.
41 Promoted properties are supported only on PHP 8.0 and later.

ondrejmirtes added a commit to phpstan/phpstan-src that referenced this issue Oct 3, 2022
ondrejmirtes referenced this issue in phpstan/phpstan-src Oct 4, 2022
@github-actions
Copy link

github-actions bot commented Nov 4, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants