-
-
Notifications
You must be signed in to change notification settings - Fork 862
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
Generics - closure type inference bug #5508
Comments
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
PHP 7.1 – 7.4 (3 errors)
==========
-37: Parameter #1 $items of class Collection constructor expects array<TMapValue>, array<TKey of (int|string), TMapValue>|false given.
+37: Parameter #1 $items of class Collection constructor expects array<TKey of (int|string), TMapValue>, array<TKey of (int|string), TMapValue>|false given.
49: Anonymous function should have native return typehint "string".
53: Expected type array<int, string>, actual: array<int, mixed> Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (3 errors)
|
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 (2 errors)
+PHP 8.0 (3 errors)
==========
+35: Parameter #1 $callback of function array_map expects callable(TValue): mixed, callable(TValue, TKey of (int|string)): TMapValue given.
49: Anonymous function should have native return typehint "string".
53: Expected type array<int, string>, actual: array<int, mixed>
-PHP 7.1 – 7.4 (3 errors)
+PHP 7.1 – 7.4 (4 errors)
==========
-37: Parameter #1 $items of class Collection constructor expects array<TMapValue>, array<TKey of (int|string), TMapValue>|false given.
+35: Parameter #1 $callback of function array_map expects callable(TValue): mixed, callable(TValue, TKey of (int|string)): TMapValue given.
+37: Parameter #1 $items of class Collection constructor expects array<TKey of (int|string), TMapValue>, array<TKey of (int|string), TMapValue>|false given.
49: Anonymous function should have native return typehint "string".
53: Expected type array<int, string>, actual: array<int, mixed> Full reportPHP 8.0 (3 errors)
PHP 7.1 – 7.4 (4 errors)
|
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 (2 errors)
+PHP 8.0 (1 error)
==========
-49: Anonymous function should have native return typehint "string".
53: Expected type array<int, string>, actual: array<int, mixed>
-PHP 7.1 – 7.4 (3 errors)
+PHP 7.1 – 7.4 (2 errors)
==========
-37: Parameter #1 $items of class Collection constructor expects array<TMapValue>, array<TKey of (int|string), TMapValue>|false given.
-49: Anonymous function should have native return typehint "string".
+37: Parameter #1 $items of class Collection constructor expects array<TKey of (int|string), TMapValue>, array<TKey of (int|string), TMapValue>|false given.
53: Expected type array<int, string>, actual: array<int, mixed> Full reportPHP 8.0 (1 error)
PHP 7.1 – 7.4 (2 errors)
|
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 (2 errors)
-==========
-
-49: Anonymous function should have native return typehint "string".
-53: Expected type array<int, string>, actual: array<int, mixed>
-
-PHP 7.1 – 7.4 (3 errors)
-==========
-
-37: Parameter #1 $items of class Collection constructor expects array<TMapValue>, array<TKey of (int|string), TMapValue>|false given.
-49: Anonymous function should have native return typehint "string".
-53: Expected type array<int, string>, actual: array<int, mixed>
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md Full report
|
@ondrejmirtes After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 (2 errors)
+PHP 8.0
==========
-49: Anonymous function should have native return typehint "string".
-53: Expected type array<int, string>, actual: array<int, mixed>
+No errors
-PHP 7.1 – 7.4 (3 errors)
+PHP 7.1 – 7.4 (1 error)
==========
-37: Parameter #1 $items of class Collection constructor expects array<TMapValue>, array<TKey of (int|string), TMapValue>|false given.
-49: Anonymous function should have native return typehint "string".
-53: Expected type array<int, string>, actual: array<int, mixed>
+37: Parameter #1 $items of class Collection constructor expects array<TKey of (int|string), TMapValue>, array<TKey of (int|string), TMapValue>|false given. Full reportPHP 8.0No errors PHP 7.1 – 7.4 (1 error)
|
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. |
Bug report
Code snippet that reproduces the problem
https://phpstan.org/r/15176d68-f91e-495d-8b23-437853a55392
Expected output
The resulting type should be
array<int, string>
The text was updated successfully, but these errors were encountered: