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

Return from declare() block is ignored #9309

Closed
hocker1 opened this issue May 12, 2023 · 6 comments
Closed

Return from declare() block is ignored #9309

hocker1 opened this issue May 12, 2023 · 6 comments
Labels
Milestone

Comments

@hocker1
Copy link

hocker1 commented May 12, 2023

Bug report

PHPStan seems to ignore code inside declare() { ... } blocks.

Code snippet that reproduces the problem

https://phpstan.org/r/626c6650-affc-4827-92ff-9f245ca2eb12

Expected output

I expected PHPStan to report that the code is ok. Instead, it reports that the return statement is missing, which is not true, there is return statement inside the declare() block.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone May 13, 2023
@ondrejmirtes
Copy link
Member

You win "the most surprising issue of 2023" award! :) https://twitter.com/OndrejMirtes/status/1657300073196265473

@phpstan-bot
Copy link
Contributor

@hocker1 After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:

@@ @@
-4: Function a() should return int but return statement is missing.
+No errors

@mad-briller
Copy link
Contributor

@ondrejmirtes this is fixed now

@ondrejmirtes
Copy link
Member

@mad-briller If you want to do the God's work, please send regression tests for these fixed issues: #5266, #9309, #9394, #6922. Thank you.

@mad-briller
Copy link
Contributor

sorry @ondrejmirtes i've been away from pc for a few days and you beat me to it

Copy link

github-actions bot commented Dec 8, 2023

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

No branches or pull requests

4 participants