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

Errors missed on arrow functions #3660

Closed
nicofff opened this issue Jul 22, 2020 · 4 comments
Closed

Errors missed on arrow functions #3660

nicofff opened this issue Jul 22, 2020 · 4 comments

Comments

@nicofff
Copy link

nicofff commented Jul 22, 2020

Bug report

Under some circumstances, the same implementation using anonymous functions will detect an issue, but if arrow functions are used, it won't.

Code snippet that reproduces the problem

https://phpstan.org/r/8dd5b2a8-e742-4577-b00a-b2bfc72184d5

Expected output

I'd expect both array_map's to raise the same issue, since the code is equivalent.

@ondrejmirtes
Copy link
Member

@phpstan-bot
Copy link
Contributor

@nicofff PHPStan now reports different result with your code snippet:

@@ @@
-5: Parameter #1 $string of function strlen expects string, int given.
+PHP 7.4 – 8.0 (1 error)
+==========
+
+5: Parameter #1 $string of function strlen expects string, int given.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+4: Syntax error, unexpected ',' on line 4
+4: Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 4
Full report

PHP 7.4 – 8.0 (1 error)

Line Error
5 Parameter #1 $string of function strlen expects string, int given.

PHP 7.1 – 7.3 (2 errors)

Line Error
4 Syntax error, unexpected ',' on line 4
4 Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 4

@phpstan-bot
Copy link
Contributor

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

@@ @@
-5: Parameter #1 $string of function strlen expects string, int given.
+PHP 7.4 – 8.0 (2 errors)
+==========
+
+4: Parameter #1 $string of function strlen expects string, int given.
+5: Parameter #1 $string of function strlen expects string, int given.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+4: Syntax error, unexpected ',' on line 4
+4: Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 4
Full report

PHP 7.4 – 8.0 (2 errors)

Line Error
4 Parameter #1 $string of function strlen expects string, int given.
5 Parameter #1 $string of function strlen expects string, int given.

PHP 7.1 – 7.3 (2 errors)

Line Error
4 Syntax error, unexpected ',' on line 4
4 Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 4

@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 Jul 28, 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

3 participants