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

Detect access to uninitialized variables in combination with the null coalescing operator (??) #2496

Closed
odan opened this issue Oct 10, 2019 · 1 comment

Comments

@odan
Copy link
Contributor

odan commented Oct 10, 2019

Bug report

PHPStan cannot detect access to uninitialized variables when using the null coalescing operator (??).

There should be a difference beetween uninitialized variables and accessing an initialized variable that could contain null.

Code snippet that reproduces the problem

https://phpstan.org/r/fc07a0fb-3326-42ca-8b12-121995e8e780

Expected output

An Error like: "Undefined variable: $foo" or "An uninitialized array is being accessed".

@ondrejmirtes
Copy link
Member

Duplicate of #1823

@ondrejmirtes ondrejmirtes marked this as a duplicate of #1823 Oct 10, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants