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

Undefined variable reported in empty #30

Closed
JanTvrdik opened this issue Dec 12, 2016 · 5 comments
Closed

Undefined variable reported in empty #30

JanTvrdik opened this issue Dec 12, 2016 · 5 comments

Comments

@JanTvrdik
Copy link
Contributor

PHPStan incorrectly reports „Undefined variable: $a“

if (empty($a)) {

}
@ondrejmirtes
Copy link
Member

Yep, supporting empty() is on the roadmap, I discussed it today with @mzk.

@JanTvrdik JanTvrdik changed the title Undefined variable repoted in empty Undefined variable reported in empty Dec 13, 2016
@rquadling
Copy link
Contributor

In unset() included in this also?

// $set may or may not be empty.
foreach($set as $index => &$row) {
}
unset($row); // Undefined variable.

One solution I've seen is to put the unset() inside the foreach() loop.

@ondrejmirtes
Copy link
Member

I'll look into that.

@ondrejmirtes
Copy link
Member

unset is fixed (8ce4738), empty is still in the works.

@ondrejmirtes
Copy link
Member

Support for empty() is in 10eb46d.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 21, 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

3 participants