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

Empty check should fail on undefined var #970

Closed
muglug opened this issue May 1, 2018 · 3 comments
Closed

Empty check should fail on undefined var #970

muglug opened this issue May 1, 2018 · 3 comments

Comments

@muglug
Copy link
Contributor

muglug commented May 1, 2018

function foo(array $arr) : void {
    if (!empty($ar['foo'])) {
        // do something
    }
}

Expected: $ar is undefined
Actual: No issue

Replacing !empty with isset triggers the correct output.

@ondrejmirtes
Copy link
Member

Hi, yep, I plan to do this but not in the next version - first, I need to correctly implement isset for Scope::getType(), then I need to implement loose comparison operators for Scope::getType() and then I'm able to say that empty($expr) is just !isset($expr) || $expr == false which is what the PHP documentation is saying 😊

@ondrejmirtes
Copy link
Member

Implemented: phpstan/phpstan-src@9689fbd

@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 Oct 12, 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

2 participants