-
-
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
Polymorphic anonymous functions #10685
Comments
in your flip-zip example, are you sure that the expected output is it's hard to tell without the code bodies, but assuming the parameters become flipped, the result should be backwards right? |
You right. Expected output should be
Right. You guessed what the functions do. |
@klimick After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.1 – 8.3 (1 error)
+PHP 8.1 – 8.3 (2 errors)
==========
-26: Dumped type: Closure(A): A
+26: Dumped type: Closure<A of mixed>(A): A
+28: Call to function acceptsPoly() on a separate line has no effect.
-PHP 7.2 – 8.0 (2 errors)
+PHP 7.2 – 8.0 (3 errors)
==========
22: First-class callables are supported only on PHP 8.1 and later.
-26: Dumped type: Closure(A): A
+26: Dumped type: Closure<A of mixed>(A): A
+28: Call to function acceptsPoly() on a separate line has no effect. Full reportPHP 8.1 – 8.3 (2 errors)
PHP 7.2 – 8.0 (3 errors)
|
@klimick After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
32: Dumped type: callable(list<B>, list<A>): list<array{A, B}>
36: Dumped type: list<array{2, 2}>
-37: Parameter #1 $ of callable callable(list<B>, list<A>): list<array{A, B}> expects list<2>, array{1} given.
+37: Parameter #1 of callable callable(list<B>, list<A>): list<array{A, B}> expects list<2>, array{1} given.
PHP 7.2 – 8.0 (4 errors)
==========
@@ @@
29: First-class callables are supported only on PHP 8.1 and later.
32: Dumped type: callable(list<B>, list<A>): list<array{A, B}>
36: Dumped type: list<array{2, 2}>
-37: Parameter #1 $ of callable callable(list<B>, list<A>): list<array{A, B}> expects list<2>, array{1} given.
+37: Parameter #1 of callable callable(list<B>, list<A>): list<array{A, B}> expects list<2>, array{1} given. Full reportPHP 8.1 – 8.3 (3 errors)
PHP 7.2 – 8.0 (4 errors)
|
Bug report
The new feature for callable type from 1.10.60 release does not work well.
Most easiest case of usage:
https://phpstan.org/r/870d442a-918b-4ea8-8181-afe38d8faae2
Type representation dumps incorrectly:
https://phpstan.org/r/294502a4-683d-4dc7-a7f5-24b07291ec22
Other (can be mind blowing):
https://phpstan.org/r/0efe72eb-b394-4de7-b2d5-a04f59fe6667
https://phpstan.org/r/15a337f8-fdcc-484c-9db0-766ed55740b0
Code snippet that reproduces the problem
No response
Expected output
I tried to describe it in examples
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: