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

Report wrong type expected by an array_map closure #5356

Closed
ondrejmirtes opened this issue Jul 21, 2021 · 3 comments
Closed

Report wrong type expected by an array_map closure #5356

ondrejmirtes opened this issue Jul 21, 2021 · 3 comments

Comments

@ondrejmirtes
Copy link
Member

Feature request

https://phpstan.org/r/2c752186-1a20-465a-9e94-0be9cb120669

https://phpstan.org/r/b9bc584a-db2a-46e3-8382-b6c69a4ff93e

@ondrejmirtes ondrejmirtes added this to the Generics milestone Jul 21, 2021
@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-PHP 7.4 – 8.0
+PHP 7.4 – 8.0 (1 error)
 ==========
 
-No errors
+6: Parameter #1 $callback of function array_map expects callable(string): mixed, Closure(array): 'a' given.
 
 PHP 7.1 – 7.3 (3 errors)
 ==========
Full report

PHP 7.4 – 8.0 (1 error)

Line Error
6 Parameter #1 $callback of function array_map expects callable(string): mixed, Closure(array): 'a' given.

PHP 7.1 – 7.3 (3 errors)

Line Error
6 Syntax error, unexpected ')' on line 6
6 Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 6
6 Syntax error, unexpected T_VARIABLE, expecting ':' on line 6

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-No errors
+6: Parameter #1 $callback of function array_map expects callable(string): mixed, Closure(array): 'a' given.
Full report
Line Error
6 Parameter #1 $callback of function array_map expects callable(string): mixed, Closure(array): 'a' given.

ondrejmirtes added a commit to phpstan/phpstan-src that referenced this issue Sep 12, 2021
mglaman pushed a commit to mglaman/phpstan-src that referenced this issue Oct 7, 2021
@github-actions
Copy link

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 Oct 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants