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

phpstan assumes _SESSION always exists #4586

Closed
staabm opened this issue Feb 22, 2021 · 6 comments
Closed

phpstan assumes _SESSION always exists #4586

staabm opened this issue Feb 22, 2021 · 6 comments
Labels
Milestone

Comments

@staabm
Copy link
Contributor

staabm commented Feb 22, 2021

Bug report

Code snippet that reproduces the problem

I dont expect the error we get at https://phpstan.org/r/34e05837-1aa9-41f2-8a74-0d3b30f7f54d
since the super global $_SESSION is only defined after session_start() is called

see https://3v4l.org/0a8Ie vs. https://3v4l.org/GlBZ2

Expected output

no error

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Feb 22, 2021
@ondrejmirtes
Copy link
Member

This fix is probably wrong. phpstan/phpstan-src#321

@sjerdo
Copy link

sjerdo commented Feb 27, 2021

For some reason the inverse does not trigger any error: https://phpstan.org/r/65dbfe18-b20e-4655-a280-935f5089d1f3

@phpstan-bot
Copy link
Contributor

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

@@ @@
-10: Unreachable statement - code above always terminates.
+ 5: Method HelloWorld::sayHello() should return bool but return statement is missing.
Full report
Line Error
5 Method HelloWorld::sayHello() should return bool but return statement is missing.

@phpstan-bot
Copy link
Contributor

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

@@ @@
-No errors
+5: Method HelloWorld::sayHello() should return bool but return statement is missing.
Full report
Line Error
5 Method HelloWorld::sayHello() should return bool but return statement is missing.

@phpstan-bot
Copy link
Contributor

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

@@ @@
-10: Unreachable statement - code above always terminates.
+No errors

@github-actions
Copy link

github-actions bot commented Mar 4, 2022

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 Mar 4, 2022
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