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

Match arm comparison between *NEVER* and array{t1: bool, t2: bool} is always false. #6647

Closed
levu42 opened this issue Feb 14, 2022 · 2 comments · Fixed by phpstan/phpstan-src#1504
Labels
Milestone

Comments

@levu42
Copy link

levu42 commented Feb 14, 2022

Bug report

When combining an array that has is_null() calls in its constructor and a match instruction, I get the array type to be reported *NEVER*.

Match arm comparison between NEVER and array{t1: bool, t2: bool} is always false.

Code snippet that reproduces the problem

https://phpstan.org/r/d70c5c30-8cb5-4811-8c3f-ba6b8a29bab7

Expected output

That code should be fine, at least it works perfectly well.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Feb 14, 2022
@phpstan-bot
Copy link
Contributor

@levu42 After the latest commit in 1.8.x, PHPStan now reports different result with your code snippet:

@@ @@
-PHP 8.0 – 8.1 (1 error)
+PHP 8.0 – 8.1
 ==========
 
-22: Match arm comparison between *NEVER* and array{t1: bool, t2: bool} is always false.
+No errors
 
 PHP 7.4 (3 errors)
 ==========
Full report

PHP 8.0 – 8.1

No errors

PHP 7.4 (3 errors)

Line Error
21 Syntax error, unexpected T_DOUBLE_ARROW on line 21
22 Syntax error, unexpected T_DOUBLE_ARROW on line 22
25 Syntax error, unexpected ',' on line 25

PHP 7.1 – 7.3 (4 errors)

Line Error
15 Syntax error, unexpected T_VARIABLE, expecting ')' on line 15
21 Syntax error, unexpected T_DOUBLE_ARROW on line 21
22 Syntax error, unexpected T_DOUBLE_ARROW on line 22
25 Syntax error, unexpected ',' on line 25

@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 Aug 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants